Skip to content

Commit

Permalink
fat: use fat_fs_error() instead of BUG_ON() in __fat_get_block()
Browse files Browse the repository at this point in the history
If file size and FAT cluster chain is not matched (corrupted image), we
can hit BUG_ON(!phys) in __fat_get_block().

So, use fat_fs_error() instead.

[[email protected]: fix printk warning]
  Link: http://lkml.kernel.org/r/[email protected]
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: OGAWA Hirofumi <[email protected]>
Reported-by: Anatoly Trosinenko <[email protected]>
Tested-by: Anatoly Trosinenko <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
OGAWAHirofumi authored and torvalds committed Jun 14, 2018
1 parent 26b9513 commit c2574aa
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion fs/fat/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,14 @@ static inline int __fat_get_block(struct inode *inode, sector_t iblock,
err = fat_bmap(inode, iblock, &phys, &mapped_blocks, create, false);
if (err)
return err;
if (!phys) {
fat_fs_error(sb,
"invalid FAT chain (i_pos %lld, last_block %llu)",
MSDOS_I(inode)->i_pos,
(unsigned long long)last_block);
return -EIO;
}

BUG_ON(!phys);
BUG_ON(*max_blocks != mapped_blocks);
set_buffer_new(bh_result);
map_bh(bh_result, sb, phys);
Expand Down

0 comments on commit c2574aa

Please sign in to comment.