Skip to content

Commit

Permalink
[PATCH] ext2: prevent div-by-zero on corrupted fs
Browse files Browse the repository at this point in the history
Mounting an ext2 filesystem with zero s_inodes_per_group will cause a
divide error.

Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Andries Brouwer authored and Linus Torvalds committed Aug 27, 2006
1 parent f5fb09f commit 607eb26
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion fs/ext2/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
if (EXT2_INODE_SIZE(sb) == 0)
goto cantfind_ext2;
sbi->s_inodes_per_block = sb->s_blocksize / EXT2_INODE_SIZE(sb);
if (sbi->s_inodes_per_block == 0)
if (sbi->s_inodes_per_block == 0 || sbi->s_inodes_per_group == 0)
goto cantfind_ext2;
sbi->s_itb_per_group = sbi->s_inodes_per_group /
sbi->s_inodes_per_block;
Expand Down

0 comments on commit 607eb26

Please sign in to comment.