]> git.baikalelectronics.ru Git - uboot.git/commit
fs: fat: fix fatwrite overflow calculation
authorReno Farnesi <nfarnesi4@gmail.com>
Sun, 13 Aug 2017 19:16:17 +0000 (15:16 -0400)
committerTom Rini <trini@konsulko.com>
Sat, 26 Aug 2017 18:56:07 +0000 (14:56 -0400)
commit1e2881fea05342e2b3401fb47f204e0949356b59
treee61f208578e0f134e99501753545e89d8a16c424
parent5073f2ef679dffea88d64eee345a27bbdd16d974
fs: fat: fix fatwrite overflow calculation

The overflow calculation was incorrect. Adding the start block of the
partition is not needed because the sectors are already relative to the
beginning of the partition. If you attempted to write a file smaller
than cur_part_info.start blocks on a full partition the old calculation
fails to catch the overflow. This would cause an infinite loop in the
determine_fatent function.

Old, incorrect calculation:

ending sector of new file = start sector + file size (in sectors)
last sector = partition start + total sectors on the partition

Adding the partition start block number is not needed because sectors
are already relative to the start of the partition.

New calculation:

ending sector of new file = start sector + file size (in sectors)
last sector = total sectors on the partition

Signed-off-by: Reno Farnesi <nfarnesi4@gmail.com>
fs/fat/fat_write.c