From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:46443) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RWNYM-0003aA-60 for qemu-devel@nongnu.org; Fri, 02 Dec 2011 02:29:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RWNYL-0002Q4-Ak for qemu-devel@nongnu.org; Fri, 02 Dec 2011 02:29:02 -0500 Received: from e28smtp02.in.ibm.com ([122.248.162.2]:40723) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RWNYK-0002Pe-NZ for qemu-devel@nongnu.org; Fri, 02 Dec 2011 02:29:01 -0500 Received: from /spool/local by e28smtp02.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 2 Dec 2011 12:58:52 +0530 Message-ID: <4ED87E29.1010207@linux.vnet.ibm.com> Date: Fri, 02 Dec 2011 15:28:41 +0800 From: Mark Wu MIME-Version: 1.0 References: <1322796863-3475-1-git-send-email-zhihuili@linux.vnet.ibm.com> In-Reply-To: <1322796863-3475-1-git-send-email-zhihuili@linux.vnet.ibm.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] qemu-nbd.c : fix memory leak List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Li Zhi Hui Cc: qemu-trivial@nongnu.org, qemu-devel@nongnu.org, stefanha@linux.vnet.ibm.com On 12/02/2011 11:34 AM, Li Zhi Hui wrote: > Signed-off-by: Li Zhi Hui > --- > 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.