Btrfs: Free correct pointer after using strsep

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>
This commit is contained in:
Tero Roponen 2010-12-27 16:43:13 +08:00 committed by Li Zefan
parent bdc924bb4c
commit 3f3d0bc0df

View file

@ -277,7 +277,7 @@ static int btrfs_parse_early_options(const char *options, fmode_t flags,
struct btrfs_fs_devices **fs_devices) struct btrfs_fs_devices **fs_devices)
{ {
substring_t args[MAX_OPT_ARGS]; substring_t args[MAX_OPT_ARGS];
char *opts, *p; char *opts, *orig, *p;
int error = 0; int error = 0;
int intarg; int intarg;
@ -291,6 +291,7 @@ static int btrfs_parse_early_options(const char *options, fmode_t flags,
opts = kstrdup(options, GFP_KERNEL); opts = kstrdup(options, GFP_KERNEL);
if (!opts) if (!opts)
return -ENOMEM; return -ENOMEM;
orig = opts;
while ((p = strsep(&opts, ",")) != NULL) { while ((p = strsep(&opts, ",")) != NULL) {
int token; int token;
@ -326,7 +327,7 @@ static int btrfs_parse_early_options(const char *options, fmode_t flags,
} }
out_free_opts: out_free_opts:
kfree(opts); kfree(orig);
out: out:
/* /*
* If no subvolume name is specified we use the default one. Allocate * If no subvolume name is specified we use the default one. Allocate