linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tero Roponen <tero.roponen@gmail.com>
To: linux-btrfs@vger.kernel.org
Cc: chris.mason@oracle.com, josef@redhat.com
Subject: btrfs: Free correct pointer after using strsep
Date: Mon, 30 Aug 2010 16:14:06 +0300 (EEST)	[thread overview]
Message-ID: <alpine.LFD.2.00.1008301609440.10601@localhost6.localdomain6> (raw)

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

                 reply	other threads:[~2010-08-30 13:14 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.LFD.2.00.1008301609440.10601@localhost6.localdomain6 \
    --to=tero.roponen@gmail.com \
    --cc=chris.mason@oracle.com \
    --cc=josef@redhat.com \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).