From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45999) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XI37T-0001hZ-EY for qemu-devel@nongnu.org; Thu, 14 Aug 2014 18:03:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XI37K-0002a2-9c for qemu-devel@nongnu.org; Thu, 14 Aug 2014 18:03:39 -0400 Message-ID: <53ED3224.70801@gmail.com> Date: Fri, 15 Aug 2014 06:03:16 +0800 From: Chen Gang MIME-Version: 1.0 References: <53DE5538.1020701@gmail.com> <20140814164945.2a0290fb@redhat.com> In-Reply-To: <20140814164945.2a0290fb@redhat.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] dump.c: Fix memory leak issue in cleanup processing for dump_init() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Luiz Capitulino Cc: qemu-trivial@nongnu.org, Michael Tokarev , agraf@suse.de, qemu-devel@nongnu.org, qiaonuohan@cn.fujitsu.com, pbonzini@redhat.com, lersek@redhat.com On 08/15/2014 04:49 AM, Luiz Capitulino wrote: > On Sun, 03 Aug 2014 23:28:56 +0800 > Chen Gang wrote: > >> > In dump_init(), when failure occurs, need notice about 'fd' and memory >> > mapping. So call dump_cleanup() for it (need let all initializations at >> > front). >> > >> > Also simplify dump_cleanup(): remove redundant 'ret' and redundant 'fd' >> > checking. >> > >> > Signed-off-by: Chen Gang > Applied to the qmp branch, thanks. > Thanks. > PS: I still find it hard to track the file-descriptor's life time. IMO, > the best would be to always release it where it's allocated which is > qmp_dump_guest_memory(). > If it is really hard to track, for me, I prefer to let dump_cleanup() common enough, so can simplify every members thinking. When use genric *_cleanup(), it means the resource manage management is a little complex, need use a generic cleanup function for it to be sure that every thing is not missed, and always save enough. Thanks. -- Chen Gang Open share and attitude like air water and life which God blessed