Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 607eb266 authored by Andries Brouwer's avatar Andries Brouwer Committed by Linus Torvalds
Browse files

[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: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent f5fb09fa
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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;