Skip to content

Commit

Permalink
Btrfs: fix subvol_name leak on error in btrfs_mount()
Browse files Browse the repository at this point in the history
btrfs_parse_early_options() can fail due to error while scanning devices
(-o device= option), but still strdup() subvol_name string:

mount -o subvol=SUBV,device=BAD_DEVICE <dev> <mnt>

So free subvol_name string on error.

Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
  • Loading branch information
Ilya Dryomov committed Nov 9, 2011
1 parent a90e8b6 commit f23c8af
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion fs/btrfs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -905,8 +905,10 @@ static struct dentry *btrfs_mount(struct file_system_type *fs_type, int flags,
error = btrfs_parse_early_options(data, mode, fs_type,
&subvol_name, &subvol_objectid,
&subvol_rootid, &fs_devices);
if (error)
if (error) {
kfree(subvol_name);
return ERR_PTR(error);
}

if (subvol_name) {
root = mount_subvol(subvol_name, flags, device_name, data);
Expand Down

0 comments on commit f23c8af

Please sign in to comment.