Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

fat: fix fat_ra_init() for data clusters == 0

If data clusters == 0, fat_ra_init() calls the ->ent_blocknr() for the
cluster beyond ->max_clusters.

This checks the limit before initialization to suppress the warning.

Reported-by: syzbot+756199124937b31a9b7e@syzkaller.appspotmail.com
Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Link: http://lkml.kernel.org/r/87mu462sv4.fsf@mail.parknet.co.jp
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

OGAWA Hirofumi and committed by
Linus Torvalds
a090a5a7 4ecfed61

+3
+3
fs/fat/fatent.c
··· 657 657 unsigned long ra_pages = sb->s_bdi->ra_pages; 658 658 unsigned int reada_blocks; 659 659 660 + if (fatent->entry >= ent_limit) 661 + return; 662 + 660 663 if (ra_pages > sb->s_bdi->io_pages) 661 664 ra_pages = rounddown(ra_pages, sb->s_bdi->io_pages); 662 665 reada_blocks = ra_pages << (PAGE_SHIFT - sb->s_blocksize_bits + 1);