Skip to content

Commit

Permalink
fat: fix fat_ra_init() for data clusters == 0
Browse files Browse the repository at this point in the history
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: [email protected]
Signed-off-by: OGAWA Hirofumi <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
OGAWAHirofumi authored and torvalds committed Aug 12, 2020
1 parent 4ecfed6 commit a090a5a
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions fs/fat/fatent.c
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,9 @@ static void fat_ra_init(struct super_block *sb, struct fatent_ra *ra,
unsigned long ra_pages = sb->s_bdi->ra_pages;
unsigned int reada_blocks;

if (fatent->entry >= ent_limit)
return;

if (ra_pages > sb->s_bdi->io_pages)
ra_pages = rounddown(ra_pages, sb->s_bdi->io_pages);
reada_blocks = ra_pages << (PAGE_SHIFT - sb->s_blocksize_bits + 1);
Expand Down

0 comments on commit a090a5a

Please sign in to comment.