From 7bbc53ba5ca8c488498cc1f8a66de4e3bad5372c Mon Sep 17 00:00:00 2001 Message-Id: <7bbc53ba5ca8c488498cc1f8a66de4e3bad5372c.1387276076.git.minovotn@redhat.com> In-Reply-To: References: From: Amos Kong Date: Sat, 23 Nov 2013 03:17:43 +0100 Subject: [PATCH 03/16] virtio-net: fix the memory leak in rxfilter_notify() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit RH-Author: Amos Kong Message-id: <1385176664-3852-2-git-send-email-akong@redhat.com> Patchwork-id: 55866 O-Subject: [RHEL-7.0 qemu-kvm PATCH 1/2] virtio-net: fix the memory leak in rxfilter_notify() Bugzilla: 1033810 RH-Acked-by: Vlad Yasevich RH-Acked-by: Stefan Hajnoczi RH-Acked-by: Igor Mammedov object_get_canonical_path() returns a gchar*, it should be freed by the caller. Signed-off-by: Amos Kong Reviewed-by: Michael S. Tsirkin Reviewed-by: Vlad Yasevich Reviewed-by: Andreas Färber Signed-off-by: Stefan Hajnoczi (cherry picked from commit 96e35046e4a97df5b4e1e24e217eb1e1701c7c71) --- hw/net/virtio-net.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) Signed-off-by: Michal Novotny --- 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 3bc1eed..915aa70 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 = qemu_get_nic_opaque(nc); if (nc->rxfilter_notify_enabled) { + gchar *path = object_get_canonical_path(OBJECT(n->qdev)); 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); + g_free(path); /* disable event notification to avoid events flooding */ nc->rxfilter_notify_enabled = 0; -- 1.7.11.7