diff options
author | Shen Feng <shen@cn.fujitsu.com> | 2009-01-05 15:43:42 -0500 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2009-01-05 15:43:42 -0500 |
commit | 1f48366084a7b046bcb7741ed4e607774f96e3da (patch) | |
tree | e85d1e0dccccc78689a833373933c001c5d05adb /fs/btrfs | |
parent | c584482b47f47b051cdc1d5236b99ad18f1b1cfb (diff) |
Btrfs: fix a memory leak in btrfs_get_sb
subvol_name should be freed if error occurs.
Signed-off-by: Shen Feng <shen@cn.fujitsu.com>
Diffstat (limited to 'fs/btrfs')
-rw-r--r-- | fs/btrfs/super.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index 3814238d6eba..ccdcb7bb7ad8 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c | |||
@@ -429,7 +429,7 @@ static int btrfs_get_sb(struct file_system_type *fs_type, int flags, | |||
429 | error = btrfs_parse_early_options(data, mode, fs_type, | 429 | error = btrfs_parse_early_options(data, mode, fs_type, |
430 | &subvol_name, &fs_devices); | 430 | &subvol_name, &fs_devices); |
431 | if (error) | 431 | if (error) |
432 | goto error; | 432 | return error; |
433 | 433 | ||
434 | error = btrfs_scan_one_device(dev_name, mode, fs_type, &fs_devices); | 434 | error = btrfs_scan_one_device(dev_name, mode, fs_type, &fs_devices); |
435 | if (error) | 435 | if (error) |
@@ -468,7 +468,7 @@ static int btrfs_get_sb(struct file_system_type *fs_type, int flags, | |||
468 | if (error) { | 468 | if (error) { |
469 | up_write(&s->s_umount); | 469 | up_write(&s->s_umount); |
470 | deactivate_super(s); | 470 | deactivate_super(s); |
471 | goto error; | 471 | goto error_free_subvol_name; |
472 | } | 472 | } |
473 | 473 | ||
474 | btrfs_sb(s)->fs_info->bdev_holder = fs_type; | 474 | btrfs_sb(s)->fs_info->bdev_holder = fs_type; |
@@ -485,14 +485,14 @@ static int btrfs_get_sb(struct file_system_type *fs_type, int flags, | |||
485 | up_write(&s->s_umount); | 485 | up_write(&s->s_umount); |
486 | deactivate_super(s); | 486 | deactivate_super(s); |
487 | error = PTR_ERR(root); | 487 | error = PTR_ERR(root); |
488 | goto error; | 488 | goto error_free_subvol_name; |
489 | } | 489 | } |
490 | if (!root->d_inode) { | 490 | if (!root->d_inode) { |
491 | dput(root); | 491 | dput(root); |
492 | up_write(&s->s_umount); | 492 | up_write(&s->s_umount); |
493 | deactivate_super(s); | 493 | deactivate_super(s); |
494 | error = -ENXIO; | 494 | error = -ENXIO; |
495 | goto error; | 495 | goto error_free_subvol_name; |
496 | } | 496 | } |
497 | } | 497 | } |
498 | 498 | ||
@@ -508,7 +508,6 @@ error_close_devices: | |||
508 | btrfs_close_devices(fs_devices); | 508 | btrfs_close_devices(fs_devices); |
509 | error_free_subvol_name: | 509 | error_free_subvol_name: |
510 | kfree(subvol_name); | 510 | kfree(subvol_name); |
511 | error: | ||
512 | return error; | 511 | return error; |
513 | } | 512 | } |
514 | 513 | ||