From: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
To: Eric Sandeen <sandeen@redhat.com>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 08/16] btrfs-progs: fix resource leak in scrub_start()
Date: Thu, 07 Nov 2013 13:06:53 +0800 [thread overview]
Message-ID: <527B1FED.4070604@cn.fujitsu.com> (raw)
In-Reply-To: <527B0D18.3080704@redhat.com>
On 11/07/2013 11:46 AM, Eric Sandeen wrote:
> On 11/6/13, 7:50 PM, Wang Shilong wrote:
>> On 11/07/2013 09:48 AM, Wang Shilong wrote:
>>> Hi Eric,
>>>
>>> On 11/07/2013 07:15 AM, Eric Sandeen wrote:
>>>> In the "nothing to resume" case we return directly and leak
>>>> several bits of memory; goto out to free them properly.
>>>>
>>>> Resolves-Coverity-CID: 1125934
>>>> Resolves-Coverity-CID: 1125935
>>>> Resolves-Coverity-CID: 1125936
>>>> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
>>>> ---
>>>> cmds-scrub.c | 3 ++-
>>>> 1 files changed, 2 insertions(+), 1 deletions(-)
>>>>
>>>> diff --git a/cmds-scrub.c b/cmds-scrub.c
>>>> index 605af45..5f3eade 100644
>>>> --- a/cmds-scrub.c
>>>> +++ b/cmds-scrub.c
>>>> @@ -1261,7 +1261,8 @@ static int scrub_start(int argc, char **argv, int resume)
>>>> if (!do_quiet)
>>>> printf("scrub: nothing to resume for %s, fsid %s\n",
>>>> path, fsid);
>>>> - return 2;
>>>> + err = 2;
>>>> + goto out;
>>> Thanks for tracking this problem, but
>>> i intend to return 2 in such case originally.
>>> return '!err' will revert to return 1 rather than 2.
>> see label out:
>>
>> if (err)
>> return 1
>>
> Ah, whoops. Ok, well we still need to fix the leak.
>
> I just expected that setting err & going to out would return err ;)
>
> So probably:
>
> if (err)
> return err;
No, we can't.
maybe add a flag, something like:
flag = 0;
/* we set flag here for a special case */
if (!do_quient)
printf....
flag = 2;
then in label
out:
...
/* this happen if nothing resume */
if (flag)
return flag
/* syntax or other error happens */
if (err)
return 1
Previously, 'err' can be an casual positive numbers or error number.
However, we define that we return 1 if syntax error happens.
Thanks,
Wang
>
> will work.
>
> I'll send a V2.
>
> Thanks for catching it on review!
>
> -Eric
>
>
next prev parent reply other threads:[~2013-11-07 5:10 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-06 23:15 [PATCH 00/16] btrfs-progs: Several more static analysis defect fixes Eric Sandeen
2013-11-06 23:15 ` [PATCH 01/16] btrfs-progs: fix potential double-frees in cmd_subvol_delete() Eric Sandeen
2013-11-06 23:15 ` [PATCH 02/16] btrfs-progs: fix error returns in get_df() Eric Sandeen
2013-11-07 2:33 ` Anand Jain
2013-11-06 23:15 ` [PATCH 03/16] btrfs-progs: use strncpy in btrfs_scan_lblkid() Eric Sandeen
2013-11-07 2:43 ` [PATCH] " Anand Jain
2013-11-06 23:15 ` [PATCH 04/16] btrfs-progs: fix test for return of realpath in find_mount_root() Eric Sandeen
2013-11-07 2:55 ` Anand Jain
2013-11-06 23:15 ` [PATCH 05/16] btrfs-progs: don't leak fd in test_dev_for_mkfs() error paths Eric Sandeen
2013-11-07 3:05 ` Anand Jain
2013-11-06 23:15 ` [PATCH 06/16] btrfs-progs: fix leak of "buf" in make_btrfs() " Eric Sandeen
2013-11-06 23:15 ` [PATCH 07/16] btrfs-progs: don't leak buffer on add_file_items() error Eric Sandeen
2013-11-06 23:15 ` [PATCH 08/16] btrfs-progs: fix resource leak in scrub_start() Eric Sandeen
2013-11-07 1:48 ` Wang Shilong
2013-11-07 1:50 ` Wang Shilong
2013-11-07 3:46 ` Eric Sandeen
2013-11-07 5:06 ` Wang Shilong [this message]
2013-11-06 23:15 ` [PATCH 09/16] btrfs-progs: btrfs_scan_kernel(): fd==0 is not an error Eric Sandeen
2013-11-07 4:29 ` Anand Jain
2013-11-06 23:15 ` [PATCH 10/16] btrfs-progs: Check for open failure in btrfs_scan_lblkid() Eric Sandeen
2013-11-06 23:15 ` [PATCH 11/16] btrfs-progs: pass positive errno to strerror in cmd_df() Eric Sandeen
2013-11-07 4:43 ` Anand Jain
2013-11-06 23:15 ` [PATCH 12/16] btrfs-progs: remove more dead code from check_extent_refs Eric Sandeen
2013-11-06 23:15 ` [PATCH 13/16] btrfs-progs: check btrfs_scan_one_device in btrfs_scan_lblkid() Eric Sandeen
2013-11-07 8:34 ` Anand Jain
2013-11-06 23:15 ` [PATCH 14/16] btrfs-progs: check for fstat failure in cmd_defrag Eric Sandeen
2013-11-06 23:15 ` [PATCH 15/16] btrfs-progs: annotate fallthroughs in parse_size Eric Sandeen
2013-11-06 23:15 ` [PATCH 16/16] btrfs-progs: annotate fallthroughs in parse_limit Eric Sandeen
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=527B1FED.4070604@cn.fujitsu.com \
--to=wangsl.fnst@cn.fujitsu.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=sandeen@redhat.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;
as well as URLs for NNTP newsgroup(s).