qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Weil <sw@weilnetz.de>
To: Mark Wu <wudxw@linux.vnet.ibm.com>
Cc: qemu-trivial@nongnu.org, Li Zhi Hui <zhihuili@linux.vnet.ibm.com>,
	qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] qemu-nbd.c : fix memory leak
Date: Fri, 02 Dec 2011 08:42:43 +0100	[thread overview]
Message-ID: <4ED88173.2040505@weilnetz.de> (raw)
In-Reply-To: <4ED87E29.1010207@linux.vnet.ibm.com>

Am 02.12.2011 08:28, schrieb Mark Wu:
> On 12/02/2011 11:34 AM, Li Zhi Hui wrote:
>> Signed-off-by: Li Zhi Hui<zhihuili@linux.vnet.ibm.com>
>> ---
>>   qemu-nbd.c |    4 +++-
>>   1 files changed, 3 insertions(+), 1 deletions(-)
>>
>> diff --git a/qemu-nbd.c b/qemu-nbd.c
>> index 291cba2..ab7fa6c 100644
>> --- a/qemu-nbd.c
>> +++ b/qemu-nbd.c
>> @@ -500,8 +500,10 @@ int main(int argc, char **argv)
>>           sharing_fds[0] = tcp_socket_incoming(bindto, port);
>>       }
>>
>> -    if (sharing_fds[0] == -1)
>> +    if (sharing_fds[0] == -1) {
>> +        g_free(sharing_fds);
>>           return 1;
>> +    }
>>
>>       if (device) {
>>           int ret;
> Zhihui,
>
> Kernel should free all memory used by the process after it exits.  So  
> there's no memory leak even without explicit free.

That's correct. Nevertheless fixing this helps to find other more important
memory leaks with static or dynamic code analyzers like cppcheck or 
valgrind.

Reviewed-by: Stefan Weil <sw@weilnetz.de>

  reply	other threads:[~2011-12-02  7:43 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-02  3:34 [Qemu-devel] [PATCH] qemu-nbd.c : fix memory leak Li Zhi Hui
2011-12-02  7:28 ` Mark Wu
2011-12-02  7:42   ` Stefan Weil [this message]
2011-12-02  7:48     ` Paolo Bonzini
2011-12-02 11:08       ` Stefan Hajnoczi
2011-12-02  7:53     ` Zhi Hui Li

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=4ED88173.2040505@weilnetz.de \
    --to=sw@weilnetz.de \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    --cc=wudxw@linux.vnet.ibm.com \
    --cc=zhihuili@linux.vnet.ibm.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).