linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* btrfs: Free correct pointer after using strsep
@ 2010-08-30 13:14 Tero Roponen
  0 siblings, 0 replies; only message in thread
From: Tero Roponen @ 2010-08-30 13:14 UTC (permalink / raw)
  To: linux-btrfs; +Cc: chris.mason, josef

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>

diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 1776dbd..9e2c9ec 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -260,7 +260,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;
 
@@ -275,6 +275,8 @@ static int btrfs_parse_early_options(const char *options, fmode_t flags,
 	if (!opts)
 		return -ENOMEM;
 
+	orig = opts;
+
 	while ((p = strsep(&opts, ",")) != NULL) {
 		int token;
 		if (!*p)
@@ -309,7 +311,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

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2010-08-30 13:14 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-30 13:14 btrfs: Free correct pointer after using strsep Tero Roponen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).