summaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorStefan Brüns <stefan.bruens@rwth-aachen.de>2017-01-26 20:22:36 (GMT)
committerTom Rini <trini@konsulko.com>2017-01-28 19:04:51 (GMT)
commitb352caea752f9e840863ade43da67ff0272e8594 (patch)
treed507bc1c0b51a8a010dafe235bd40c33265bfe6e /fs
parenta55bed1208b0e912f9a0025039b9740b692933d2 (diff)
downloadu-boot-fsl-qoriq-b352caea752f9e840863ade43da67ff0272e8594.tar.xz
fs/fat: Fix unaligned __u16 reads for FAT12 access
Doing unaligned reads is not supported on all architectures, use byte sized reads of the little endian buffer. Rename off16 to off8, as it reflects the buffer offset in byte granularity (offset is in entry, i.e. 12 bit, granularity). Fix a regression introduced in 8d48c92b45aea91e2a2be90f2ed93677e85526f1 Reported-by: Oleksandr Tymoshenko <gonzo@bluezbox.com> Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de> Tested-by: Oleksandr Tymoshenko <gonzo@bluezbox.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/fat/fat.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/fs/fat/fat.c b/fs/fat/fat.c
index 244ee09..5654003 100644
--- a/fs/fat/fat.c
+++ b/fs/fat/fat.c
@@ -179,7 +179,7 @@ int flush_dirty_fat_buffer(fsdata *mydata)
static __u32 get_fatent(fsdata *mydata, __u32 entry)
{
__u32 bufnum;
- __u32 off16, offset;
+ __u32 offset, off8;
__u32 ret = 0x00;
if (CHECK_CLUST(entry, mydata->fatsize)) {
@@ -242,8 +242,9 @@ static __u32 get_fatent(fsdata *mydata, __u32 entry)
ret = FAT2CPU16(((__u16 *) mydata->fatbuf)[offset]);
break;
case 12:
- off16 = (offset * 3) / 2;
- ret = FAT2CPU16(*(__u16 *)(mydata->fatbuf + off16));
+ off8 = (offset * 3) / 2;
+ /* fatbut + off8 may be unaligned, read in byte granularity */
+ ret = mydata->fatbuf[off8] + (mydata->fatbuf[off8 + 1] << 8);
if (offset & 0x1)
ret >>= 4;