From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dario Faggioli Subject: Re: [PATCH v2] libxc: fix leak of t_info in xc_tbuf_get_size() Date: Thu, 11 Feb 2016 11:03:16 +0100 Message-ID: <1455184996.3148.282.camel@citrix.com> References: <1455179579-3476-1-git-send-email-write.harmandeep@gmail.com> <1455184369.814.15.camel@citrix.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============2950803094011771923==" Return-path: Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aTo5t-00017y-LJ for xen-devel@lists.xenproject.org; Thu, 11 Feb 2016 10:03:25 +0000 In-Reply-To: <1455184369.814.15.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: Ian Campbell , Harmandeep Kaur , xen-devel@lists.xenproject.org, George Dunlap Cc: wei.liu2@citrix.com, ian.jackson@eu.citrix.com, stefano.stabellini@eu.citrix.com List-Id: xen-devel@lists.xenproject.org --===============2950803094011771923== Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-5zm0zS1efv+PV0wki1wY" --=-5zm0zS1efv+PV0wki1wY Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, 2016-02-11 at 09:52 +0000, Ian Campbell wrote: > On Thu, 2016-02-11 at 14:02 +0530, Harmandeep Kaur wrote: > >=C2=A0 > > diff --git a/tools/libxc/xc_tbuf.c b/tools/libxc/xc_tbuf.c > > index 695939a..d96cc67 100644 > > --- a/tools/libxc/xc_tbuf.c > > +++ b/tools/libxc/xc_tbuf.c > > @@ -70,11 +70,13 @@ int xc_tbuf_get_size(xc_interface *xch, > > unsigned long > > *size) > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0sysctl.u.tbuf_op.b= uffer_mfn); > > =C2=A0 > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0if ( t_info =3D=3D NULL || t_info->tbuf_s= ize =3D=3D 0 ) > > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0return -1; > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0rc =3D -1; > > +=C2=A0=C2=A0=C2=A0=C2=A0else > > + *size =3D t_info->tbuf_size; > > =C2=A0 > > -=C2=A0=C2=A0=C2=A0=C2=A0*size =3D t_info->tbuf_size; > > +=C2=A0=C2=A0=C2=A0=C2=A0xenforeignmemory_unmap(xch->fmem, t_info, *siz= e); >=20 > *size could be uninitialised here (in the error path) and even in the > success case I don't think t_info->tbus_size is the right argument > here, it > needs to be the size which was passed to the map function, i.e. > sysctl.u.tbuf_op.size. >=20 And I think both are issues with the current code, and, more important, not what Coverity is complaining about in the referenced CID? To be clear, I'm not arguing that they're not issues we should fix (I don't know about the tbuf_size vs. tbuf_op.size, but I can check). I'm genuinely asking whether we should do that here, as compared to in a pre or follow up patch, and let this one be the one that placates Coverity on that particular issue. Regards, Dario --=20 <> (Raistlin Majere) ----------------------------------------------------------------- Dario Faggioli, Ph.D, http://about.me/dario.faggioli Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK) --=-5zm0zS1efv+PV0wki1wY Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iEYEABECAAYFAla8XGQACgkQk4XaBE3IOsR0cwCfWWExVA218NkMv12GqsI12sRT H3EAn2S1VVa7Ky1mvkGxpaBstM3VZu1P =LGFh -----END PGP SIGNATURE----- --=-5zm0zS1efv+PV0wki1wY-- --===============2950803094011771923== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --===============2950803094011771923==--