From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dario Faggioli Subject: Re: [PATCH 13/28] libxl: only free cputopology if it was allocated in libxl_{cpu, node}map_to_{node, cpu}map Date: Wed, 18 Sep 2013 10:18:30 +0200 Message-ID: <1379492310.18543.54.camel@Abyss> References: <1379475484-25993-1-git-send-email-mattjd@gmail.com> <1379475484-25993-14-git-send-email-mattjd@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============5254711072780611334==" Return-path: In-Reply-To: <1379475484-25993-14-git-send-email-mattjd@gmail.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: Matthew Daley Cc: Stefano Stabellini , Ian Jackson , Ian Campbell , xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org --===============5254711072780611334== Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-+v11XC7kQhit5wYWmzdG" --=-+v11XC7kQhit5wYWmzdG Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On mer, 2013-09-18 at 15:37 +1200, Matthew Daley wrote: > Coverity-ID: 1055294 > Coverity-ID: 1055295 > Ok, forgive my coverity ignorance and sorry if I should know this already, but I do I use these IDs to get some useful information? > Signed-off-by: Matthew Daley > --- > tools/libxl/libxl_utils.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) >=20 > diff --git a/tools/libxl/libxl_utils.c b/tools/libxl/libxl_utils.c > index 4309e5e..8e567a8 100644 > --- a/tools/libxl/libxl_utils.c > +++ b/tools/libxl/libxl_utils.c > @@ -664,7 +664,8 @@ int libxl_nodemap_to_cpumap(libxl_ctx *ctx, > libxl_bitmap_set(cpumap, i); > } > out: > - libxl_cputopology_list_free(tinfo, nr_cpus); > + if (tinfo !=3D NULL) > + libxl_cputopology_list_free(tinfo, nr_cpus); > return rc; > } I was about to reply exactly as in the other e-mail (the reply to 12/28), but in this case I think there is some small rom for issues, since nr_cpus is not initialized. In fact, libxl_nodemap_to_cpumap() looks like this: 648 it libxl_nodemap_to_cpumap(libxl_ctx *ctx, 649 const libxl_bitmap *nodemap, 650 libxl_bitmap *cpumap) 651 { 652 libxl_cputopology *tinfo =3D NULL; 653 int nr_cpus, i, rc =3D 0; 654=20 655 tinfo =3D libxl_get_cpu_topology(ctx, &nr_cpus); 656 if (tinfo =3D=3D NULL) { 657 rc =3D ERROR_FAIL; 658 goto out; 659 } 660=20 661 libxl_bitmap_set_none(cpumap); 662 for (i =3D 0; i < nr_cpus; i++) { 663 if (libxl_bitmap_test(nodemap, tinfo[i].node)) 664 libxl_bitmap_set(cpumap, i); 665 } 666 out: 667 libxl_cputopology_list_free(tinfo, nr_cpus); 668 return rc; 669 } Still, I think I'd like this fixed by doing something like this: 653 int nr_cpus =3D 0, i, rc =3D 0; rather than with what this patch does, for the same reasons already explained in the other e-mails. I'm up for sending such patch myself, but that will be in a while, as right now I'm away from my workstation. Is that fine with you? > =20 > @@ -685,7 +686,8 @@ int libxl_cpumap_to_nodemap(libxl_ctx *ctx, > libxl_for_each_set_bit(i, *cpumap) > libxl_bitmap_set(nodemap, tinfo[i].node); > out: > - libxl_cputopology_list_free(tinfo, nr_cpus); > + if (tinfo !=3D NULL) > + libxl_cputopology_list_free(tinfo, nr_cpus); > return rc; > } > =20 And the same applies here, of course. Is that fine with you guys? Regards, Dario --=20 <> (Raistlin Majere) ----------------------------------------------------------------- Dario Faggioli, Ph.D, http://about.me/dario.faggioli Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK) --=-+v11XC7kQhit5wYWmzdG 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.4.14 (GNU/Linux) iEYEABECAAYFAlI5YdYACgkQk4XaBE3IOsSEegCffPMMXNyv8I5bQfUa7pcwQ/5P +9IAn2v3qZ74Yn5zStHLjQBO5h143ZMA =gS5m -----END PGP SIGNATURE----- --=-+v11XC7kQhit5wYWmzdG-- --===============5254711072780611334== 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 --===============5254711072780611334==--