From: Ilya Dryomov <idryomov@gmail.com>
To: linux-btrfs@vger.kernel.org
Cc: Chris Mason <chris.mason@oracle.com>, linux-kernel@vger.kernel.org
Subject: [PATCH] Btrfs: fix memory leak in btrfs_parse_early_options()
Date: Mon, 17 Jan 2011 21:39:10 +0200 [thread overview]
Message-ID: <20110117193910.GA26094@kwango.lan.net> (raw)
strsep() modifies the string pointer, therefore freeing it instead of
original one results in a small memory leak. Fixes kmemleak warning.
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
---
fs/btrfs/super.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 883c6fa..291b630 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, *opts_orig, *p;
int error = 0;
int intarg;
@@ -288,7 +288,7 @@ static int btrfs_parse_early_options(const char *options, fmode_t flags,
* strsep changes the string, duplicate it because parse_options
* gets called twice
*/
- opts = kstrdup(options, GFP_KERNEL);
+ opts = opts_orig = kstrdup(options, GFP_KERNEL);
if (!opts)
return -ENOMEM;
@@ -326,7 +326,7 @@ static int btrfs_parse_early_options(const char *options, fmode_t flags,
}
out_free_opts:
- kfree(opts);
+ kfree(opts_orig);
out:
/*
* If no subvolume name is specified we use the default one. Allocate
--
1.7.2.3
reply other threads:[~2011-01-17 19:39 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=20110117193910.GA26094@kwango.lan.net \
--to=idryomov@gmail.com \
--cc=chris.mason@oracle.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-kernel@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