Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/hch/hfsplus

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/hch/hfsplus:
hfsplus: fix up a comparism in hfsplus_file_extend
hfsplus: fix two memory leaks in wrapper.c
hfsplus: do not leak buffer on error
hfsplus: fix failed mount handling

+66 -50
+2 -2
fs/hfsplus/extents.c
··· 397 397 u32 start, len, goal; 398 398 int res; 399 399 400 - if (sbi->total_blocks - sbi->free_blocks + 8 > 401 - sbi->alloc_file->i_size * 8) { 400 + if (sbi->alloc_file->i_size * 8 < 401 + sbi->total_blocks - sbi->free_blocks + 8) { 402 402 /* extend alloc file */ 403 403 printk(KERN_ERR "hfs: extend alloc file! " 404 404 "(%llu,%u,%u)\n",
+2 -2
fs/hfsplus/part_tbl.c
··· 134 134 res = hfsplus_submit_bio(sb->s_bdev, *part_start + HFS_PMAP_BLK, 135 135 data, READ); 136 136 if (res) 137 - return res; 137 + goto out; 138 138 139 139 switch (be16_to_cpu(*((__be16 *)data))) { 140 140 case HFS_OLD_PMAP_MAGIC: ··· 147 147 res = -ENOENT; 148 148 break; 149 149 } 150 - 150 + out: 151 151 kfree(data); 152 152 return res; 153 153 }
+60 -44
fs/hfsplus/super.c
··· 338 338 struct inode *root, *inode; 339 339 struct qstr str; 340 340 struct nls_table *nls = NULL; 341 - int err = -EINVAL; 341 + int err; 342 342 343 + err = -EINVAL; 343 344 sbi = kzalloc(sizeof(*sbi), GFP_KERNEL); 344 345 if (!sbi) 345 - return -ENOMEM; 346 + goto out; 346 347 347 348 sb->s_fs_info = sbi; 348 349 mutex_init(&sbi->alloc_mutex); 349 350 mutex_init(&sbi->vh_mutex); 350 351 hfsplus_fill_defaults(sbi); 352 + 353 + err = -EINVAL; 351 354 if (!hfsplus_parse_options(data, sbi)) { 352 355 printk(KERN_ERR "hfs: unable to parse mount options\n"); 353 - err = -EINVAL; 354 - goto cleanup; 356 + goto out_unload_nls; 355 357 } 356 358 357 359 /* temporarily use utf8 to correctly find the hidden dir below */ ··· 361 359 sbi->nls = load_nls("utf8"); 362 360 if (!sbi->nls) { 363 361 printk(KERN_ERR "hfs: unable to load nls for utf8\n"); 364 - err = -EINVAL; 365 - goto cleanup; 362 + goto out_unload_nls; 366 363 } 367 364 368 365 /* Grab the volume header */ 369 366 if (hfsplus_read_wrapper(sb)) { 370 367 if (!silent) 371 368 printk(KERN_WARNING "hfs: unable to find HFS+ superblock\n"); 372 - err = -EINVAL; 373 - goto cleanup; 369 + goto out_unload_nls; 374 370 } 375 371 vhdr = sbi->s_vhdr; 376 372 ··· 377 377 if (be16_to_cpu(vhdr->version) < HFSPLUS_MIN_VERSION || 378 378 be16_to_cpu(vhdr->version) > HFSPLUS_CURRENT_VERSION) { 379 379 printk(KERN_ERR "hfs: wrong filesystem version\n"); 380 - goto cleanup; 380 + goto out_free_vhdr; 381 381 } 382 382 sbi->total_blocks = be32_to_cpu(vhdr->total_blocks); 383 383 sbi->free_blocks = be32_to_cpu(vhdr->free_blocks); ··· 421 421 sbi->ext_tree = hfs_btree_open(sb, HFSPLUS_EXT_CNID); 422 422 if (!sbi->ext_tree) { 423 423 printk(KERN_ERR "hfs: failed to load extents file\n"); 424 - goto cleanup; 424 + goto out_free_vhdr; 425 425 } 426 426 sbi->cat_tree = hfs_btree_open(sb, HFSPLUS_CAT_CNID); 427 427 if (!sbi->cat_tree) { 428 428 printk(KERN_ERR "hfs: failed to load catalog file\n"); 429 - goto cleanup; 429 + goto out_close_ext_tree; 430 430 } 431 431 432 432 inode = hfsplus_iget(sb, HFSPLUS_ALLOC_CNID); 433 433 if (IS_ERR(inode)) { 434 434 printk(KERN_ERR "hfs: failed to load allocation file\n"); 435 435 err = PTR_ERR(inode); 436 - goto cleanup; 436 + goto out_close_cat_tree; 437 437 } 438 438 sbi->alloc_file = inode; 439 439 ··· 442 442 if (IS_ERR(root)) { 443 443 printk(KERN_ERR "hfs: failed to load root directory\n"); 444 444 err = PTR_ERR(root); 445 - goto cleanup; 446 - } 447 - sb->s_d_op = &hfsplus_dentry_operations; 448 - sb->s_root = d_alloc_root(root); 449 - if (!sb->s_root) { 450 - iput(root); 451 - err = -ENOMEM; 452 - goto cleanup; 445 + goto out_put_alloc_file; 453 446 } 454 447 455 448 str.len = sizeof(HFSP_HIDDENDIR_NAME) - 1; ··· 452 459 if (!hfs_brec_read(&fd, &entry, sizeof(entry))) { 453 460 hfs_find_exit(&fd); 454 461 if (entry.type != cpu_to_be16(HFSPLUS_FOLDER)) 455 - goto cleanup; 462 + goto out_put_root; 456 463 inode = hfsplus_iget(sb, be32_to_cpu(entry.folder.id)); 457 464 if (IS_ERR(inode)) { 458 465 err = PTR_ERR(inode); 459 - goto cleanup; 466 + goto out_put_root; 460 467 } 461 468 sbi->hidden_dir = inode; 462 469 } else 463 470 hfs_find_exit(&fd); 464 471 465 - if (sb->s_flags & MS_RDONLY) 466 - goto out; 472 + if (!(sb->s_flags & MS_RDONLY)) { 473 + /* 474 + * H+LX == hfsplusutils, H+Lx == this driver, H+lx is unused 475 + * all three are registered with Apple for our use 476 + */ 477 + vhdr->last_mount_vers = cpu_to_be32(HFSP_MOUNT_VERSION); 478 + vhdr->modify_date = hfsp_now2mt(); 479 + be32_add_cpu(&vhdr->write_count, 1); 480 + vhdr->attributes &= cpu_to_be32(~HFSPLUS_VOL_UNMNT); 481 + vhdr->attributes |= cpu_to_be32(HFSPLUS_VOL_INCNSTNT); 482 + hfsplus_sync_fs(sb, 1); 467 483 468 - /* H+LX == hfsplusutils, H+Lx == this driver, H+lx is unused 469 - * all three are registered with Apple for our use 470 - */ 471 - vhdr->last_mount_vers = cpu_to_be32(HFSP_MOUNT_VERSION); 472 - vhdr->modify_date = hfsp_now2mt(); 473 - be32_add_cpu(&vhdr->write_count, 1); 474 - vhdr->attributes &= cpu_to_be32(~HFSPLUS_VOL_UNMNT); 475 - vhdr->attributes |= cpu_to_be32(HFSPLUS_VOL_INCNSTNT); 476 - hfsplus_sync_fs(sb, 1); 484 + if (!sbi->hidden_dir) { 485 + mutex_lock(&sbi->vh_mutex); 486 + sbi->hidden_dir = hfsplus_new_inode(sb, S_IFDIR); 487 + hfsplus_create_cat(sbi->hidden_dir->i_ino, root, &str, 488 + sbi->hidden_dir); 489 + mutex_unlock(&sbi->vh_mutex); 477 490 478 - if (!sbi->hidden_dir) { 479 - mutex_lock(&sbi->vh_mutex); 480 - sbi->hidden_dir = hfsplus_new_inode(sb, S_IFDIR); 481 - hfsplus_create_cat(sbi->hidden_dir->i_ino, sb->s_root->d_inode, 482 - &str, sbi->hidden_dir); 483 - mutex_unlock(&sbi->vh_mutex); 484 - 485 - hfsplus_mark_inode_dirty(sbi->hidden_dir, HFSPLUS_I_CAT_DIRTY); 491 + hfsplus_mark_inode_dirty(sbi->hidden_dir, 492 + HFSPLUS_I_CAT_DIRTY); 493 + } 486 494 } 487 - out: 495 + 496 + sb->s_d_op = &hfsplus_dentry_operations; 497 + sb->s_root = d_alloc_root(root); 498 + if (!sb->s_root) { 499 + err = -ENOMEM; 500 + goto out_put_hidden_dir; 501 + } 502 + 488 503 unload_nls(sbi->nls); 489 504 sbi->nls = nls; 490 505 return 0; 491 506 492 - cleanup: 493 - hfsplus_put_super(sb); 507 + out_put_hidden_dir: 508 + iput(sbi->hidden_dir); 509 + out_put_root: 510 + iput(sbi->alloc_file); 511 + out_put_alloc_file: 512 + iput(sbi->alloc_file); 513 + out_close_cat_tree: 514 + hfs_btree_close(sbi->cat_tree); 515 + out_close_ext_tree: 516 + hfs_btree_close(sbi->ext_tree); 517 + out_free_vhdr: 518 + kfree(sbi->s_vhdr); 519 + kfree(sbi->s_backup_vhdr); 520 + out_unload_nls: 521 + unload_nls(sbi->nls); 494 522 unload_nls(nls); 523 + kfree(sbi); 524 + out: 495 525 return err; 496 526 } 497 527
+2 -2
fs/hfsplus/wrapper.c
··· 167 167 break; 168 168 case cpu_to_be16(HFSP_WRAP_MAGIC): 169 169 if (!hfsplus_read_mdb(sbi->s_vhdr, &wd)) 170 - goto out; 170 + goto out_free_backup_vhdr; 171 171 wd.ablk_size >>= HFSPLUS_SECTOR_SHIFT; 172 172 part_start += wd.ablk_start + wd.embed_start * wd.ablk_size; 173 173 part_size = wd.embed_count * wd.ablk_size; ··· 179 179 * (should do this only for cdrom/loop though) 180 180 */ 181 181 if (hfs_part_find(sb, &part_start, &part_size)) 182 - goto out; 182 + goto out_free_backup_vhdr; 183 183 goto reread; 184 184 } 185 185