]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
btrfs: trivial fix, a potential memory leak in btrfs_parse_early_options()
authorJeff Liu <jeff.liu@oracle.com>
Wed, 14 Sep 2011 06:11:21 +0000 (14:11 +0800)
committerChris Mason <chris.mason@oracle.com>
Wed, 16 Nov 2011 02:20:39 +0000 (21:20 -0500)
Signed-off-by: Jie Liu <jeff.liu@oracle.com>
(cherry picked from commit 83c8c9bde0add721f7509aa446455183b040b931)

fs/btrfs/super.c

index e04156c1428103a68c917ccc4203e37994e6a627..ae475fe559bdf0086ba3f9eebaaa5bdda982de1c 100644 (file)
@@ -419,7 +419,7 @@ static int btrfs_parse_early_options(const char *options, fmode_t flags,
                u64 *subvol_rootid, struct btrfs_fs_devices **fs_devices)
 {
        substring_t args[MAX_OPT_ARGS];
-       char *opts, *orig, *p;
+       char *device_name, *opts, *orig, *p;
        int error = 0;
        int intarg;
 
@@ -470,8 +470,14 @@ static int btrfs_parse_early_options(const char *options, fmode_t flags,
                        }
                        break;
                case Opt_device:
-                       error = btrfs_scan_one_device(match_strdup(&args[0]),
+                       device_name = match_strdup(&args[0]);
+                       if (!device_name) {
+                               error = -ENOMEM;
+                               goto out;
+                       }
+                       error = btrfs_scan_one_device(device_name,
                                        flags, holder, fs_devices);
+                       kfree(device_name);
                        if (error)
                                goto out;
                        break;