Patchwork [PULL,09/13] qom: fix leak for objects created with -object

login
register
mail settings
Submitter Luiz Capitulino
Date Dec. 18, 2013, 4:59 p.m.
Message ID <1387386003-8949-10-git-send-email-lcapitulino@redhat.com>
Download mbox | patch
Permalink /patch/303000/
State New
Headers show

Comments

Luiz Capitulino - Dec. 18, 2013, 4:59 p.m.
From: Paolo Bonzini <pbonzini@redhat.com>

The object must be unref-ed when its variable goes out of scope.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-By: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 vl.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Patch

diff --git a/vl.c b/vl.c
index 1f189d3..fcf2cc3 100644
--- a/vl.c
+++ b/vl.c
@@ -2811,12 +2811,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;
 }