From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43774) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ViPAw-0002SP-Tp for qemu-devel@nongnu.org; Mon, 18 Nov 2013 08:47:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ViPAq-0007V2-Ul for qemu-devel@nongnu.org; Mon, 18 Nov 2013 08:47:38 -0500 Received: from mx1.redhat.com ([209.132.183.28]:50584) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ViPAq-0007Uw-Mt for qemu-devel@nongnu.org; Mon, 18 Nov 2013 08:47:32 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id rAIDlVIP010276 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 18 Nov 2013 08:47:31 -0500 From: Amos Kong Date: Mon, 18 Nov 2013 21:47:25 +0800 Message-Id: <1384782445-26527-1-git-send-email-akong@redhat.com> Subject: [Qemu-devel] [PATCH] virtio-net: fix the memory leak in rxfilter_notify() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: vyasevic@redhat.com, stefanha@redhat.com, mst@redhat.com object_get_canonical_path() returns a gchar*, it should be freeed by the caller. Signed-off-by: Amos Kong --- hw/net/virtio-net.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 613f144..2b2fb57 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -198,15 +198,14 @@ static void rxfilter_notify(NetClientState *nc) { QObject *event_data; VirtIONet *n = qemu_get_nic_opaque(nc); + gchar *path = object_get_canonical_path(OBJECT(n->qdev)); if (nc->rxfilter_notify_enabled) { if (n->netclient_name) { event_data = qobject_from_jsonf("{ 'name': %s, 'path': %s }", - n->netclient_name, - object_get_canonical_path(OBJECT(n->qdev))); + n->netclient_name, path); } else { - event_data = qobject_from_jsonf("{ 'path': %s }", - object_get_canonical_path(OBJECT(n->qdev))); + event_data = qobject_from_jsonf("{ 'path': %s }", path); } monitor_protocol_event(QEVENT_NIC_RX_FILTER_CHANGED, event_data); qobject_decref(event_data); @@ -214,6 +213,7 @@ static void rxfilter_notify(NetClientState *nc) /* disable event notification to avoid events flooding */ nc->rxfilter_notify_enabled = 0; } + g_free(path); } static char *mac_strdup_printf(const uint8_t *mac) -- 1.8.3.1