Btrfs: fix subvol_name leak on error in btrfs_mount()
authorIlya Dryomov <idryomov@gmail.com>
Tue, 8 Nov 2011 17:15:05 +0000 (19:15 +0200)
committerIlya Dryomov <idryomov@gmail.com>
Wed, 9 Nov 2011 20:53:38 +0000 (22:53 +0200)
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>
fs/btrfs/super.c

index 6befcaf253bd7e03175b5a1a241c227827d84a81..58e9492230ce82ec560ae243293bb008fe8a6e2b 100644 (file)
@@ -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);