summaryrefslogtreecommitdiffstats
path: root/fs/btrfs/super.c
diff options
context:
space:
mode:
authorTero Roponen <tero.roponen@gmail.com>2010-12-27 09:43:13 +0100
committerLi Zefan <lizf@cn.fujitsu.com>2011-01-26 18:05:11 +0100
commit3f3d0bc0df041236fad4ffa82188a6e4ef9af75e (patch)
treeb27b210a3c48e08e63d1ee69c9b4b7e86709e360 /fs/btrfs/super.c
parentBtrfs: Fix memory leak on finding existing super (diff)
downloadlinux-3f3d0bc0df041236fad4ffa82188a6e4ef9af75e.tar.xz
linux-3f3d0bc0df041236fad4ffa82188a6e4ef9af75e.zip
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>
Diffstat (limited to 'fs/btrfs/super.c')
-rw-r--r--fs/btrfs/super.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index f50253c2279d..78ee681465af 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -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;
@@ -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;
@@ -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