Bug 1033810

Summary: memory leak in using object_get_canonical_path()
Product: Red Hat Enterprise Linux 7 Reporter: Amos Kong <akong>
Component: qemu-kvmAssignee: Amos Kong <akong>
Status: CLOSED CURRENTRELEASE QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.0CC: acathrow, ailan, areis, hhuang, juzhang, michen, shu, virt-maint, xuhan
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: qemu-kvm-1.5.3-22.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-06-13 13:09:20 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

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.