From 94aea467c98a6130224997105a8a8431bfac8331 Mon Sep 17 00:00:00 2001 From: Christopher Haster Date: Tue, 27 Jun 2017 15:39:44 -0500 Subject: [PATCH] fatfs: Fix unaligned access in disk_ioctl Unlike the other disk_ioctl options, GET_SECTOR_SIZE is interpreted as a 16-bit WORD, instead of a 32-bit DWORD. This caused an unaligned access error on M0 platforms. --- features/filesystem/fat/FATFileSystem.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/features/filesystem/fat/FATFileSystem.cpp b/features/filesystem/fat/FATFileSystem.cpp index cfd09aa122..3fa35ecaaf 100644 --- a/features/filesystem/fat/FATFileSystem.cpp +++ b/features/filesystem/fat/FATFileSystem.cpp @@ -219,8 +219,8 @@ DRESULT disk_ioctl(BYTE pdrv, BYTE cmd, void *buff) if (_ffs[pdrv] == NULL) { return RES_NOTRDY; } else { - DWORD size = _ffs[pdrv]->get_erase_size(); - *((DWORD*)buff) = size; + WORD size = _ffs[pdrv]->get_erase_size(); + *((WORD*)buff) = size; return RES_OK; } case GET_BLOCK_SIZE: