Commit c2574aaa authored by OGAWA Hirofumi's avatar OGAWA Hirofumi Committed by Linus Torvalds
Browse files

fat: use fat_fs_error() instead of BUG_ON() in __fat_get_block()

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.

[ fix printk warning]

Signed-off-by: default avatarOGAWA Hirofumi <>
Reported-by: default avatarAnatoly Trosinenko <>
Tested-by: default avatarAnatoly Trosinenko <>
Signed-off-by: default avatarAndrew Morton <>
Signed-off-by: default avatarLinus Torvalds <>
parent 26b95137
......@@ -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) {
"invalid FAT chain (i_pos %lld, last_block %llu)",
(unsigned long long)last_block);
return -EIO;
BUG_ON(*max_blocks != mapped_blocks);
map_bh(bh_result, sb, phys);
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment