[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: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by Andries Brouwer and committed by Linus Torvalds f5fb09fa fb8d81e4

+10 -3
+10 -3
fs/minix/inode.c
··· 204 /* 205 * Allocate the buffer map to keep the superblock small. 206 */ 207 i = (sbi->s_imap_blocks + sbi->s_zmap_blocks) * sizeof(bh); 208 map = kmalloc(i, GFP_KERNEL); 209 if (!map) ··· 265 266 out_no_bitmap: 267 printk("MINIX-fs: bad superblock or unable to read bitmaps\n"); 268 - out_freemap: 269 for (i = 0; i < sbi->s_imap_blocks; i++) 270 brelse(sbi->s_imap[i]); 271 for (i = 0; i < sbi->s_zmap_blocks; i++) ··· 278 printk("MINIX-fs: can't allocate map\n"); 279 goto out_release; 280 281 out_no_fs: 282 if (!silent) 283 printk("VFS: Can't find a Minix or Minix V2 filesystem " 284 "on device %s\n", s->s_id); 285 - out_release: 286 brelse(bh); 287 goto out; 288 ··· 297 298 out_bad_sb: 299 printk("MINIX-fs: unable to read superblock\n"); 300 - out: 301 s->s_fs_info = NULL; 302 kfree(sbi); 303 return -EINVAL;
··· 204 /* 205 * Allocate the buffer map to keep the superblock small. 206 */ 207 + if (sbi->s_imap_blocks == 0 || sbi->s_zmap_blocks == 0) 208 + goto out_illegal_sb; 209 i = (sbi->s_imap_blocks + sbi->s_zmap_blocks) * sizeof(bh); 210 map = kmalloc(i, GFP_KERNEL); 211 if (!map) ··· 263 264 out_no_bitmap: 265 printk("MINIX-fs: bad superblock or unable to read bitmaps\n"); 266 + out_freemap: 267 for (i = 0; i < sbi->s_imap_blocks; i++) 268 brelse(sbi->s_imap[i]); 269 for (i = 0; i < sbi->s_zmap_blocks; i++) ··· 276 printk("MINIX-fs: can't allocate map\n"); 277 goto out_release; 278 279 + out_illegal_sb: 280 + if (!silent) 281 + printk("MINIX-fs: bad superblock\n"); 282 + goto out_release; 283 + 284 out_no_fs: 285 if (!silent) 286 printk("VFS: Can't find a Minix or Minix V2 filesystem " 287 "on device %s\n", s->s_id); 288 + out_release: 289 brelse(bh); 290 goto out; 291 ··· 290 291 out_bad_sb: 292 printk("MINIX-fs: unable to read superblock\n"); 293 + out: 294 s->s_fs_info = NULL; 295 kfree(sbi); 296 return -EINVAL;