]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
[PATCH] ext2: prevent div-by-zero on corrupted fs
authorAndries Brouwer <Andries.Brouwer@cwi.nl>
Sun, 27 Aug 2006 08:23:43 +0000 (01:23 -0700)
committerLinus Torvalds <torvalds@g5.osdl.org>
Sun, 27 Aug 2006 18:01:30 +0000 (11:01 -0700)
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>
fs/ext2/super.c

index f2702cda977981673264f96c33f8d974545d9694..681dea8f9532ee744932bdc6fa9762360d892b45 100644 (file)
@@ -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;