From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59521) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ViREc-0008Ae-MC for qemu-devel@nongnu.org; Mon, 18 Nov 2013 10:59:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ViREX-0003xR-8U for qemu-devel@nongnu.org; Mon, 18 Nov 2013 10:59:34 -0500 Message-ID: <528A395B.9030803@suse.de> Date: Mon, 18 Nov 2013 16:59:23 +0100 From: =?ISO-8859-15?Q?Andreas_F=E4rber?= MIME-Version: 1.0 References: <1384788737-6233-1-git-send-email-akong@redhat.com> In-Reply-To: <1384788737-6233-1-git-send-email-akong@redhat.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v2] virtio-net: fix the memory leak in rxfilter_notify() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Amos Kong , qemu-devel@nongnu.org Cc: vyasevic@redhat.com, qemu-stable , stefanha@redhat.com, mst@redhat.com Am 18.11.2013 16:32, schrieb Amos Kong: > object_get_canonical_path() returns a gchar*, it should be freeed by th= e > caller. >=20 Cc: qemu-stable@nongnu.org > Signed-off-by: Amos Kong > --- > v2: put gchar *path inside rxfilter_notify_enabled block > --- > hw/net/virtio-net.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) >=20 > diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c > index 613f144..b75c753 100644 > --- a/hw/net/virtio-net.c > +++ b/hw/net/virtio-net.c > @@ -200,16 +200,16 @@ static void rxfilter_notify(NetClientState *nc) > VirtIONet *n =3D qemu_get_nic_opaque(nc); > =20 > if (nc->rxfilter_notify_enabled) { > + gchar *path =3D object_get_canonical_path(OBJECT(n->qdev)); > if (n->netclient_name) { > event_data =3D qobject_from_jsonf("{ 'name': %s, 'path': %= s }", > - n->netclient_name, > - object_get_canonical_path(OBJECT(n= ->qdev))); > + n->netclient_name, path); Now that the lengthy funtion call is gone, you could align the arguments inside '(', but anyway: Reviewed-by: Andreas F=E4rber Thanks, Andreas > } else { > - event_data =3D qobject_from_jsonf("{ 'path': %s }", > - object_get_canonical_path(OBJECT(n= ->qdev))); > + event_data =3D qobject_from_jsonf("{ 'path': %s }", path); > } > monitor_protocol_event(QEVENT_NIC_RX_FILTER_CHANGED, event_dat= a); > qobject_decref(event_data); > + g_free(path); > =20 > /* disable event notification to avoid events flooding */ > nc->rxfilter_notify_enabled =3D 0; >=20 --=20 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N=FCrnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imend=F6rffer; HRB 16746 AG N=FCrnbe= rg