Skip to content

Commit

Permalink
Btrfs: kfree correct pointer during mount option parsing
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Josef Bacik authored and Chris Mason committed Mar 8, 2010
1 parent 6bef4d3 commit da495ec
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions fs/btrfs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand Down Expand Up @@ -280,7 +281,7 @@ int btrfs_parse_options(struct btrfs_root *root, char *options)
}
}
out:
kfree(options);
kfree(orig);
return ret;
}

Expand Down

0 comments on commit da495ec

Please sign in to comment.