From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:60556) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RWNrk-0007dk-Gl for qemu-devel@nongnu.org; Fri, 02 Dec 2011 02:49:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RWNrj-0006Fn-Hi for qemu-devel@nongnu.org; Fri, 02 Dec 2011 02:49:04 -0500 Sender: Paolo Bonzini Message-ID: <4ED882E2.6090709@redhat.com> Date: Fri, 02 Dec 2011 08:48:50 +0100 From: Paolo Bonzini MIME-Version: 1.0 References: <1322796863-3475-1-git-send-email-zhihuili@linux.vnet.ibm.com> <4ED87E29.1010207@linux.vnet.ibm.com> <4ED88173.2040505@weilnetz.de> In-Reply-To: <4ED88173.2040505@weilnetz.de> 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: Stefan Weil Cc: qemu-trivial@nongnu.org, Li Zhi Hui , Mark Wu , qemu-devel@nongnu.org On 12/02/2011 08:42 AM, Stefan Weil wrote: >>> >>> - 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 Please hold off, I'm about to introduce large changes to qemu-nbd for asynchronous I/O (including getting rid of sharing_fds in favor of the main loop) and and I'd rather avoid gratuitous conflicts. Paolo