]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
Btrfs: kfree correct pointer during mount option parsing
authorJosef Bacik <josef@redhat.com>
Thu, 25 Feb 2010 20:38:35 +0000 (20:38 +0000)
committerGreg Kroah-Hartman <gregkh@suse.de>
Mon, 21 Mar 2011 19:44:14 +0000 (12:44 -0700)
commit da495ecc0fb096b383754952a1c152147bc95b52 upstream.

We kstrdup the options string, but then strsep screws with the pointer,
so when we kfree() it, we're not giving it the right pointer.

Tested-by: Andy Lutomirski <luto@mit.edu>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
fs/btrfs/super.c

index 8a1ea6e64575a34c507c29cd8c84ec4944885583..f8b4521de90750c32cd2347baea5e25355748066 100644 (file)
@@ -128,7 +128,7 @@ int btrfs_parse_options(struct btrfs_root *root, char *options)
 {
        struct btrfs_fs_info *info = root->fs_info;
        substring_t args[MAX_OPT_ARGS];
-       char *p, *num;
+       char *p, *num, *orig;
        int intarg;
        int ret = 0;
 
@@ -143,6 +143,7 @@ int btrfs_parse_options(struct btrfs_root *root, char *options)
        if (!options)
                return -ENOMEM;
 
+       orig = options;
 
        while ((p = strsep(&options, ",")) != NULL) {
                int token;
@@ -280,7 +281,7 @@ int btrfs_parse_options(struct btrfs_root *root, char *options)
                }
        }
 out:
-       kfree(options);
+       kfree(orig);
        return ret;
 }