From: Jeff Liu <jeff.liu@oracle.com>
To: Li Zefan <lizf@cn.fujitsu.com>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH] btrfs: trivial fix, a potential memory leak in btrfs_parse_early_options()
Date: Wed, 14 Sep 2011 14:11:21 +0800 [thread overview]
Message-ID: <4E704589.5020903@oracle.com> (raw)
In-Reply-To: <4E703E4D.3040101@cn.fujitsu.com>
On 09/14/2011 01:40 PM, Li Zefan wrote:
> 14:06, Jeff Liu wrote:
>> Signed-off-by: Jie Liu <jeff.liu@oracle.com>
>>
>> ---
>> fs/btrfs/super.c | 10 ++++++++--
>> 1 files changed, 8 insertions(+), 2 deletions(-)
>>
>> diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
>> index 15634d4..16f31e1 100644
>> --- a/fs/btrfs/super.c
>> +++ b/fs/btrfs/super.c
>> @@ -406,7 +406,7 @@ static int btrfs_parse_early_options(const char *options, fmode_t flags,
>> u64 *subvol_rootid, struct btrfs_fs_devices **fs_devices)
>> {
>> substring_t args[MAX_OPT_ARGS];
>> - char *opts, *orig, *p;
>> + char *device_name, *opts, *orig, *p;
>
> Seems your email client replaced tabs with spaces.
Fixed, thank you.
Signed-off-by: Jie Liu <jeff.liu@oracle.com>
---
fs/btrfs/super.c | 10 ++++++++--
1 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 15634d4..16f31e1 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -406,7 +406,7 @@ static int btrfs_parse_early_options(const char
*options, fmode_t flags,
u64 *subvol_rootid, struct btrfs_fs_devices **fs_devices)
{
substring_t args[MAX_OPT_ARGS];
- char *opts, *orig, *p;
+ char *device_name, *opts, *orig, *p;
int error = 0;
int intarg;
@@ -457,8 +457,14 @@ static int btrfs_parse_early_options(const char
*options, fmode_t flags,
}
break;
case Opt_device:
- error = btrfs_scan_one_device(match_strdup(&args[0]),
+ device_name = match_strdup(&args[0]);
+ if (!device_name) {
+ error = -ENOMEM;
+ goto out_free_opts;
+ }
+ error = btrfs_scan_one_device(device_name,
flags, holder, fs_devices);
+ kfree(device_name);
if (error)
goto out_free_opts;
break;
--
1.7.4.1
>
> Please read Documentation/email-clients.txt
>
>> int error = 0;
>> int intarg;
>>
>> @@ -457,8 +457,14 @@ static int btrfs_parse_early_options(const char *options, fmode_t flags,
>> }
>> break;
>> case Opt_device:
>> - error = btrfs_scan_one_device(match_strdup(&args[0]),
>> + device_name = match_strdup(&args[0]);
>> + if (!device_name) {
>> + error = -ENOMEM;
>> + goto out_free_opts;
>> + }
>> + error = btrfs_scan_one_device(device_name,
>> flags, holder, fs_devices);
>> + kfree(device_name);
>> if (error)
>> goto out_free_opts;
>> break;
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2011-09-14 6:11 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-13 6:06 [PATCH] btrfs: trivial fix, a potential memory leak in btrfs_parse_early_options() Jeff Liu
2011-09-14 5:40 ` Li Zefan
2011-09-14 6:11 ` Jeff Liu [this message]
2011-09-15 12:05 ` David Sterba
2011-09-15 15:01 ` [PATCH V2] " Jeff Liu
2011-09-15 18:07 ` David Sterba
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=4E704589.5020903@oracle.com \
--to=jeff.liu@oracle.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=lizf@cn.fujitsu.com \
/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