Skip to content

Commit 607eb26

Browse files
Andries BrouwerLinus Torvalds
authored andcommitted
[PATCH] ext2: prevent div-by-zero on corrupted fs
Mounting an ext2 filesystem with zero s_inodes_per_group will cause a divide error. Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
1 parent f5fb09f commit 607eb26

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎fs/ext2/super.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
775775
if (EXT2_INODE_SIZE(sb) == 0)
776776
goto cantfind_ext2;
777777
sbi->s_inodes_per_block = sb->s_blocksize / EXT2_INODE_SIZE(sb);
778-
if (sbi->s_inodes_per_block == 0)
778+
if (sbi->s_inodes_per_block == 0 || sbi->s_inodes_per_group == 0)
779779
goto cantfind_ext2;
780780
sbi->s_itb_per_group = sbi->s_inodes_per_group /
781781
sbi->s_inodes_per_block;

0 commit comments

Comments
 (0)