Skip to content

Commit

Permalink
Btrfs: Free correct pointer after using strsep
Browse files Browse the repository at this point in the history
We must save and free the original kstrdup()'ed pointer
because strsep() modifies its first argument.

Signed-off-by: Tero Roponen <tero.roponen@gmail.com>
Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
  • Loading branch information
Tero Roponen authored and Li Zefan committed Jan 26, 2011
1 parent bdc924b commit 3f3d0bc
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 @@ -277,7 +277,7 @@ static int btrfs_parse_early_options(const char *options, fmode_t flags,
struct btrfs_fs_devices **fs_devices)
{
substring_t args[MAX_OPT_ARGS];
char *opts, *p;
char *opts, *orig, *p;
int error = 0;
int intarg;

Expand All @@ -291,6 +291,7 @@ static int btrfs_parse_early_options(const char *options, fmode_t flags,
opts = kstrdup(options, GFP_KERNEL);
if (!opts)
return -ENOMEM;
orig = opts;

while ((p = strsep(&opts, ",")) != NULL) {
int token;
Expand Down Expand Up @@ -326,7 +327,7 @@ static int btrfs_parse_early_options(const char *options, fmode_t flags,
}

out_free_opts:
kfree(opts);
kfree(orig);
out:
/*
* If no subvolume name is specified we use the default one. Allocate
Expand Down

0 comments on commit 3f3d0bc

Please sign in to comment.