From: Amos Kong Date: Mon, 18 Nov 2013 15:32:17 +0000 (+0800) Subject: virtio-net: fix the memory leak in rxfilter_notify() X-Git-Tag: v1.7.0-rc1~23^2 X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=96e35046e4a97df5b4e1e24e217eb1e1701c7c71;p=qemu.git virtio-net: fix the memory leak in rxfilter_notify() 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 --- diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 613f144d1..b75c75330 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;