diff options
author | Andries E. Brouwer <Andries.Brouwer@cwi.nl> | 2007-12-17 19:19:55 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-12-17 22:28:16 -0500 |
commit | b47b6f38e5202c924bfe7632dce5dda4e3d40731 (patch) | |
tree | b9dfeb426adc7125ac7828d5b646d893163314c6 /fs/ext3 | |
parent | 9e2de407bec98fb07040f658f55fb71ba1b594f5 (diff) |
ext3, ext4: avoid divide by zero
As it turns out, the kernel divides by EXT3_INODES_PER_GROUP(s) when
mounting an ext3 filesystem. If that number is zero, a crash follows.
Below a patch.
This crash was reported by Joeri de Ruiter, Carst Tankink and Pim Vullers.
Cc: <linux-ext4@vger.kernel.org>
Acked-by: Alan Cox <alan@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/ext3')
-rw-r--r-- | fs/ext3/super.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/fs/ext3/super.c b/fs/ext3/super.c index de55da9e28ba..cb14de1502c3 100644 --- a/fs/ext3/super.c +++ b/fs/ext3/super.c | |||
@@ -1676,7 +1676,7 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent) | |||
1676 | sbi->s_blocks_per_group = le32_to_cpu(es->s_blocks_per_group); | 1676 | sbi->s_blocks_per_group = le32_to_cpu(es->s_blocks_per_group); |
1677 | sbi->s_frags_per_group = le32_to_cpu(es->s_frags_per_group); | 1677 | sbi->s_frags_per_group = le32_to_cpu(es->s_frags_per_group); |
1678 | sbi->s_inodes_per_group = le32_to_cpu(es->s_inodes_per_group); | 1678 | sbi->s_inodes_per_group = le32_to_cpu(es->s_inodes_per_group); |
1679 | if (EXT3_INODE_SIZE(sb) == 0) | 1679 | if (EXT3_INODE_SIZE(sb) == 0 || EXT3_INODES_PER_GROUP(sb) == 0) |
1680 | goto cantfind_ext3; | 1680 | goto cantfind_ext3; |
1681 | sbi->s_inodes_per_block = blocksize / EXT3_INODE_SIZE(sb); | 1681 | sbi->s_inodes_per_block = blocksize / EXT3_INODE_SIZE(sb); |
1682 | if (sbi->s_inodes_per_block == 0) | 1682 | if (sbi->s_inodes_per_block == 0) |