Bug 1033810 - memory leak in using object_get_canonical_path()
Summary: memory leak in using object_get_canonical_path()
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: qemu-kvm
Version: 7.0
Hardware: All
OS: Linux
medium
medium
Target Milestone: rc
: ---
Assignee: Amos Kong
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-11-23 03:00 UTC by Amos Kong
Modified: 2015-05-25 00:07 UTC (History)
9 users (show)

Fixed In Version: qemu-kvm-1.5.3-22.el7
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2014-06-13 13:09:20 UTC
Target Upstream Version:


Attachments (Terms of Use)

Description Amos Kong 2013-11-23 03:00:34 UTC
Two patches fixed the memory leak in calling rxfilter_notify(), we need to backport them.


===============================================================
commit 96e35046e4a97df5b4e1e24e217eb1e1701c7c71
Author: Amos Kong <akong>
Date:   Mon Nov 18 23:32:17 2013 +0800

    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 <akong>
    Reviewed-by: Michael S. Tsirkin <mst>
    Reviewed-by: Vlad Yasevich <vyasevic>
    Reviewed-by: Andreas Färber <afaerber>
    Signed-off-by: Stefan Hajnoczi <stefanha>

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 = 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;

===============================================================

commit 2d3aa28cc2cf382aa04cd577e0be542175eea9bd
Author: Vlad Yasevich <vyasevic>
Date:   Fri Nov 15 12:09:47 2013 -0500

    qom: Fix memory leak in object_property_set_link()
    
    Save the result of the call to object_get_canonical_path()
    so we can free it.
    
    Cc: qemu-stable
    Signed-off-by: Vlad Yasevich <vyasevic>
    Reviewed-by: Amos Kong <akong>
    Reviewed-by: Stefan Hajnoczi <stefanha>
    Signed-off-by: Andreas Färber <afaerber>

diff --git a/qom/object.c b/qom/object.c
index b617f26..fc19cf6 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -838,8 +838,9 @@ char *object_property_get_str(Object *obj, const char *name,
 void object_property_set_link(Object *obj, Object *value,
                               const char *name, Error **errp)
 {
-    object_property_set_str(obj, object_get_canonical_path(value),
-                            name, errp);
+    gchar *path = object_get_canonical_path(value);
+    object_property_set_str(obj, path, name, errp);
+    g_free(path);
 }
 
 Object *object_property_get_link(Object *obj, const char *name,

Comment 6 Shaolong Hu 2013-12-27 10:06:57 UTC
Verified patch has been applied on qemu-kvm-1.5.3-30.el7:

709b3788e91957a9cff1adbe8ceac45daa2fa2bd

and

7bbc53ba5ca8c488498cc1f8a66de4e3bad5372c

Comment 7 Ludek Smid 2014-06-13 13:09:20 UTC
This request was resolved in Red Hat Enterprise Linux 7.0.

Contact your manager or support representative in case you have further questions about the request.


Note You need to log in before you can comment on or make changes to this bug.