Commit f5fb09fa authored by Andries Brouwer's avatar Andries Brouwer Committed by Linus Torvalds

[PATCH] Fix for minix crash

Mounting a (corrupt) minix filesystem with zero s_zmap_blocks
gives a spectacular crash on my 2.6.17.8 system, no doubt
because minix/inode.c does an unconditional
	minix_set_bit(0,sbi->s_zmap[0]->b_data);

[akpm@osdl.org: make labels conistent while we're there]
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent fb8d81e4
...@@ -204,6 +204,8 @@ static int minix_fill_super(struct super_block *s, void *data, int silent) ...@@ -204,6 +204,8 @@ static int minix_fill_super(struct super_block *s, void *data, int silent)
/* /*
* Allocate the buffer map to keep the superblock small. * Allocate the buffer map to keep the superblock small.
*/ */
if (sbi->s_imap_blocks == 0 || sbi->s_zmap_blocks == 0)
goto out_illegal_sb;
i = (sbi->s_imap_blocks + sbi->s_zmap_blocks) * sizeof(bh); i = (sbi->s_imap_blocks + sbi->s_zmap_blocks) * sizeof(bh);
map = kmalloc(i, GFP_KERNEL); map = kmalloc(i, GFP_KERNEL);
if (!map) if (!map)
...@@ -263,7 +265,7 @@ static int minix_fill_super(struct super_block *s, void *data, int silent) ...@@ -263,7 +265,7 @@ static int minix_fill_super(struct super_block *s, void *data, int silent)
out_no_bitmap: out_no_bitmap:
printk("MINIX-fs: bad superblock or unable to read bitmaps\n"); printk("MINIX-fs: bad superblock or unable to read bitmaps\n");
out_freemap: out_freemap:
for (i = 0; i < sbi->s_imap_blocks; i++) for (i = 0; i < sbi->s_imap_blocks; i++)
brelse(sbi->s_imap[i]); brelse(sbi->s_imap[i]);
for (i = 0; i < sbi->s_zmap_blocks; i++) for (i = 0; i < sbi->s_zmap_blocks; i++)
...@@ -276,11 +278,16 @@ static int minix_fill_super(struct super_block *s, void *data, int silent) ...@@ -276,11 +278,16 @@ static int minix_fill_super(struct super_block *s, void *data, int silent)
printk("MINIX-fs: can't allocate map\n"); printk("MINIX-fs: can't allocate map\n");
goto out_release; goto out_release;
out_illegal_sb:
if (!silent)
printk("MINIX-fs: bad superblock\n");
goto out_release;
out_no_fs: out_no_fs:
if (!silent) if (!silent)
printk("VFS: Can't find a Minix or Minix V2 filesystem " printk("VFS: Can't find a Minix or Minix V2 filesystem "
"on device %s\n", s->s_id); "on device %s\n", s->s_id);
out_release: out_release:
brelse(bh); brelse(bh);
goto out; goto out;
...@@ -290,7 +297,7 @@ static int minix_fill_super(struct super_block *s, void *data, int silent) ...@@ -290,7 +297,7 @@ static int minix_fill_super(struct super_block *s, void *data, int silent)
out_bad_sb: out_bad_sb:
printk("MINIX-fs: unable to read superblock\n"); printk("MINIX-fs: unable to read superblock\n");
out: out:
s->s_fs_info = NULL; s->s_fs_info = NULL;
kfree(sbi); kfree(sbi);
return -EINVAL; return -EINVAL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment