Received: from eggs.gnu.org ([2001:4830:134:3::10]:50112) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bwSRA-0004Kw-Ul for qemu-devel@nongnu.org; Tue, 18 Oct 2016 07:20:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bwSR5-0007Jw-Sc for qemu-devel@nongnu.org; Tue, 18 Oct 2016 07:20:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33908) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1bwSR5-0007Je-Kr for qemu-devel@nongnu.org; Tue, 18 Oct 2016 07:19:59 -0400 References: <1476782267-2602-1-git-send-email-ptoscano@redhat.com> From: Eric Blake Message-ID: <6e9a6c76-a2f1-697a-e193-eee2e5d23a55@redhat.com> Date: Tue, 18 Oct 2016 06:19:57 -0500 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="wRX3e4Xv8E4SKnoERW6DN4rDQdduANUna" Subject: Re: [Qemu-devel] [PATCH] qapi: fix memory leak in QmpOutputVisitor List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Pino Toscano , qemu-devel@nongnu.org Cc: armbru@redhat.com, mdroth@linux.vnet.ibm.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --wRX3e4Xv8E4SKnoERW6DN4rDQdduANUna From: Eric Blake To: Pino Toscano , qemu-devel@nongnu.org Cc: armbru@redhat.com, mdroth@linux.vnet.ibm.com Message-ID: <6e9a6c76-a2f1-697a-e193-eee2e5d23a55@redhat.com> Subject: Re: [Qemu-devel] [PATCH] qapi: fix memory leak in QmpOutputVisitor References: <1476782267-2602-1-git-send-email-ptoscano@redhat.com> In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 10/18/2016 06:13 AM, Eric Blake wrote: > On 10/18/2016 04:17 AM, Pino Toscano wrote: >> qmp_output_start_struct() and qmp_output_start_list() create a new >> QObject (QDict, QList) and push it to the stack of the QmpOutputVisito= r, >> where it is saved as 'value'. When freeing the iterator in >> qmp_output_free(), these values are never freed properly. >=20 > Do any of the tests (perhaps run under valgrind) show this leak? If not= , > maybe we should enhance their coverage. >=20 >> >> The simple solution is to qobject_decref() them. >> --- >> qapi/qmp-output-visitor.c | 1 + >> 1 file changed, 1 insertion(+) >=20 > Reviewed-by: Eric Blake except this should be done against v2, where you had S-o-B :) >=20 >> >> diff --git a/qapi/qmp-output-visitor.c b/qapi/qmp-output-visitor.c >> index 9e3b67c..eedf256 100644 >> --- a/qapi/qmp-output-visitor.c >> +++ b/qapi/qmp-output-visitor.c >> @@ -220,6 +220,7 @@ static void qmp_output_free(Visitor *v) >> while (!QSLIST_EMPTY(&qov->stack)) { >> e =3D QSLIST_FIRST(&qov->stack); >> QSLIST_REMOVE_HEAD(&qov->stack, node); >> + qobject_decref(e->value); >> g_free(e); >> } >> =20 >> >=20 --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --wRX3e4Xv8E4SKnoERW6DN4rDQdduANUna 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/ iQEcBAEBCAAGBQJYBgVdAAoJEKeha0olJ0Nq/fQH/0ZL2a6wgz92NjJD7aURUsMB q4tbUJodpPxWpViFy47gO0wipociPGZbd5UcdYUJBLy3LKs+QkMT18RRqhWFpFsv FysdhpvrQDZVX2ZDD/cycSuRixWBBcpHncrEarjApn6C0zeB8+Hm0bO9ADjaRwWk pDrZabLR8OExgfD6PVqM53MqzUPSh6QJTj1jPzXQ8ghp0ZgENpVtFmG6gY4Ltsll k0vLEtnnkLwNHACJRkIHbNBCOFtkiEwp1XnRUA/OrfOocuuBoItr5DYoWa1FzUNX hffaeOPw0XfgjEMBz33gjEQ3n32sf6+Sv76I9fKu9emK8iV1Cb/ZcGJCGFROLT8= =Xru0 -----END PGP SIGNATURE----- --wRX3e4Xv8E4SKnoERW6DN4rDQdduANUna--