]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
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)
committerChris Mason <chris.mason@oracle.com>
Wed, 16 Nov 2011 02:20:57 +0000 (21:20 -0500)
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>
(cherry picked from commit f23c8af8ca2789eeb0ab9ea90c214f9694d96cc5)

fs/btrfs/super.c

index 519e674ec488f4b685bdff4570a56be372bb782b..a5df52f184b0375e28c8dd6c02a94099a891cebf 100644 (file)
@@ -917,8 +917,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);