diff mbox

[RFC,09/14] qom: fix leak for objects created with -object

Message ID 1386764361-15260-10-git-send-email-pbonzini@redhat.com
State New
Headers show

Commit Message

Paolo Bonzini Dec. 11, 2013, 12:19 p.m. UTC
The object must be unref-ed when its variable goes out of scope.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 vl.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Stefan Hajnoczi Dec. 12, 2013, 8:18 a.m. UTC | #1
On Wed, Dec 11, 2013 at 01:19:16PM +0100, Paolo Bonzini wrote:
> The object must be unref-ed when its variable goes out of scope.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  vl.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
diff mbox

Patch

diff --git a/vl.c b/vl.c
index 68ba565..086a062 100644
--- a/vl.c
+++ b/vl.c
@@ -2717,12 +2717,13 @@  static int object_create(QemuOpts *opts, void *opaque)
 
     obj = object_new(type);
     if (qemu_opt_foreach(opts, object_set_property, obj, 1) < 0) {
+        object_unref(obj);
         return -1;
     }
 
     object_property_add_child(container_get(object_get_root(), "/objects"),
                               id, obj, NULL);
-
+    object_unref(obj);
     return 0;
 }