summaryrefslogtreecommitdiff
path: root/fs/fat/fat.c
diff options
context:
space:
mode:
authorStefan Brüns <stefan.bruens@rwth-aachen.de>2016-12-17 00:27:50 +0100
committerTom Rini <trini@konsulko.com>2016-12-27 11:24:13 -0500
commit6c1a808052ba6a875df7aa450b6df4b199f3a281 (patch)
tree92e632f3ade5970513c8e6058f3946196a19d98b /fs/fat/fat.c
parentc99d1b3ccf8d6fda809bb391da9cde86157cc4c9 (diff)
downloadu-boot-imx-6c1a808052ba6a875df7aa450b6df4b199f3a281.zip
u-boot-imx-6c1a808052ba6a875df7aa450b6df4b199f3a281.tar.gz
u-boot-imx-6c1a808052ba6a875df7aa450b6df4b199f3a281.tar.bz2
fs/fat: Avoid corruption of sectors following the FAT
The FAT is read/flushed in segments of 6 (FATBUFBLOCKS) disk sectors. The last segment may be less than 6 sectors, cap the length. Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de> Reviewed-by: Benoît Thébaudeau <benoit.thebaudeau.dev@gmail.com>
Diffstat (limited to 'fs/fat/fat.c')
-rw-r--r--fs/fat/fat.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/fs/fat/fat.c b/fs/fat/fat.c
index df9f2b5..6319581 100644
--- a/fs/fat/fat.c
+++ b/fs/fat/fat.c
@@ -202,6 +202,7 @@ static __u32 get_fatent(fsdata *mydata, __u32 entry)
__u32 fatlength = mydata->fatlength;
__u32 startblock = bufnum * FATBUFBLOCKS;
+ /* Cap length if fatlength is not a multiple of FATBUFBLOCKS */
if (startblock + getsize > fatlength)
getsize = fatlength - startblock;