From: Ian Jackson Subject: Re: [PATCH] libxc: Fix CID 1351228 resource leak Date: Wed, 10 Feb 2016 11:14:52 +0000 Message-ID: <22203.7084.995481.990729@mariner.uk.xensource.com> References: <1455095385-3120-1-git-send-email-write.harmandeep@gmail.com> <1455096771.3148.172.camel@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Return-path: Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aTSjZ-0000n1-Eo for xen-devel@lists.xenproject.org; Wed, 10 Feb 2016 11:14:57 +0000 In-Reply-To: <1455096771.3148.172.camel@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Dario Faggioli Cc: xen-devel@lists.xenproject.org, ian.campbell@citrix.com, wei.liu2@citrix.com, Harmandeep Kaur , stefano.stabellini@eu.citrix.com List-Id: xen-devel@lists.xenproject.org Dario Faggioli writes ("Re: [PATCH] libxc: Fix CID 1351228 resource leak"): > On Wed, 2016-02-10 at 14:39 +0530, Harmandeep Kaur wrote: > > > What I just said about the other patch ("libxc: Fix CID 1351225 > resource leak") applies here as well, of course. :-) > = > About the code... ... > > =A0=A0=A0=A0=A0if ( t_info =3D=3D NULL || t_info->tbuf_size =3D=3D 0 ) > > +=A0=A0=A0=A0{ > > +=A0=A0=A0=A0=A0=A0=A0=A0xenforeignmemory_unmap(xch->fmem, t_info, 0); > > =A0=A0=A0=A0=A0=A0=A0=A0=A0return -1; > > +=A0=A0=A0=A0} > > =A0 > > =A0=A0=A0=A0=A0*size =3D t_info->tbuf_size; > > +=A0=A0=A0=A0xenforeignmemory_unmap(xch->fmem, t_info, *size); ... > I think you can arrange for only calling the unmapping function once, > i.e., put the unmap call in a place where (after a slight > reorganization of the rest of the code as well) it can be common to > both the success and error path. Indeed. See tools/libxl/CODING_STYLE. Ian.