From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39469) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZwzZ5-0001Tx-Rv for qemu-devel@nongnu.org; Thu, 12 Nov 2015 16:37:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZwzZ1-0003hP-R9 for qemu-devel@nongnu.org; Thu, 12 Nov 2015 16:37:55 -0500 Received: from mx1.redhat.com ([209.132.183.28]:55600) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZwzZ1-0003hC-JF for qemu-devel@nongnu.org; Thu, 12 Nov 2015 16:37:51 -0500 References: <1447323728-2427-1-git-send-email-prasanna.kalever@redhat.com> <1447323728-2427-4-git-send-email-prasanna.kalever@redhat.com> From: Eric Blake Message-ID: <564506A5.8070705@redhat.com> Date: Thu, 12 Nov 2015 14:37:41 -0700 MIME-Version: 1.0 In-Reply-To: <1447323728-2427-4-git-send-email-prasanna.kalever@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="16XxQBJuxcJMx9smGdkhgavkG3ArRREpV" Subject: Re: [Qemu-devel] [PATCH 3/4] block/gluster: using new qapi schema List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Prasanna Kumar Kalever , qemu-devel@nongnu.org Cc: kwolf@redhat.com, pkrempa@redhat.com, stefanha@gmail.com, jcody@redhat.com, deepakcs@redhat.com, bharata@linux.vnet.ibm.com, rtalur@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --16XxQBJuxcJMx9smGdkhgavkG3ArRREpV Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 11/12/2015 03:22 AM, Prasanna Kumar Kalever wrote: > this patch adds GlusterConf to qapi/block-core.json >=20 > Signed-off-by: Prasanna Kumar Kalever > --- > block/gluster.c | 104 +++++++++++++++++++++++++------------------= -------- > qapi/block-core.json | 60 +++++++++++++++++++++++++++-- > 2 files changed, 109 insertions(+), 55 deletions(-) One more comment: > -static int qemu_gluster_parseuri(GlusterConf *gconf, const char *filen= ame) > +static int qemu_gluster_parseuri(BlockdevOptionsGluster **pgconf, > + const char *filename) > { > + BlockdevOptionsGluster *gconf; > URI *uri; > QueryParams *qp =3D NULL; > bool is_unix =3D false; > @@ -155,20 +141,24 @@ static int qemu_gluster_parseuri(GlusterConf *gco= nf, const char *filename) > return -EINVAL; If we hit this early return, then *pgconf was never assigned... > +static struct glfs *qemu_gluster_init(BlockdevOptionsGluster **pgconf,= > + const char *filename, Error **er= rp) > { > - struct glfs *glfs =3D NULL; > + struct glfs *glfs; > int ret; > int old_errno; > + BlockdevOptionsGluster *gconf; but here, gconf is uninitialized, > =20 > - ret =3D qemu_gluster_parseuri(gconf, filename); > + ret =3D qemu_gluster_parseuri(&gconf, filename); > if (ret < 0) { > error_setg(errp, "Usage: file=3Dgluster[+transport]://[host[:p= ort]]/" > "volume/path[?socket=3D...]"); which means we can goto out with it uninitialized... > @@ -224,8 +225,9 @@ static struct glfs *qemu_gluster_init(GlusterConf *= gconf, const char *filename, > goto out; > } > =20 > - ret =3D glfs_set_volfile_server(glfs, gconf->transport, gconf->hos= t, > - gconf->port); > + ret =3D glfs_set_volfile_server(glfs, > + GlusterTransport_lookup[gconf->serve= r->transport], > + gconf->server->host, gconf->server->= port); > if (ret < 0) { > goto out; > } =2E..vs. here where we can goto out with it initialized. So whatever solution you use to plug the leak must be careful to not free uninitialized memory. Easiest solution - initialize gconf to NULL before qemu_gluster_parseuri (or else go back to a *gconf parameter rather than **pgconf). --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --16XxQBJuxcJMx9smGdkhgavkG3ArRREpV Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJWRQalAAoJEKeha0olJ0NqmTcH/3fUuvVoHrpI2heyv7/FRRmx d7vuYAVe486Eyzxt9/7FSHrYOCN/1OGHp+N+6facJaYbBE05bNkV8c/K5plxONyt rQL80YiToTimDyLSM26Gs1CVttvdh16+bD6a9r1tl2mmSJDMc0tOFUKeYr3/3sIO KecqXwtdZSKndnK5jh9UJt5ph5V5jJECjsxs/Rl4wzfrdxmjxXU/zORdhkIbFiwN vMgIkt5XPSb9dsfI3k5LPRwG94wACbUtUSDpp6WOcquXyvKCg5Jj6klddD6uOy0o +zrsI1t/LcCfNkZ8CfO5KyDP5JoGwUs/zUInyjFOB17Jqc/cPoeNSvB+AJPM8P4= =0gYt -----END PGP SIGNATURE----- --16XxQBJuxcJMx9smGdkhgavkG3ArRREpV--