qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: imammedo@redhat.com, afaerber@suse.de, lcapitulino@xilinx.com
Subject: [Qemu-devel] [PATCH v3 2/5] qom: fix leak for objects created with -object
Date: Fri, 20 Dec 2013 23:21:07 +0100	[thread overview]
Message-ID: <1387578070-2884-3-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1387578070-2884-1-git-send-email-pbonzini@redhat.com>

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(-)

diff --git a/vl.c b/vl.c
index 7511e70..45f9177 100644
--- a/vl.c
+++ b/vl.c
@@ -2809,12 +2809,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;
 }
 
-- 
1.8.4.2

  parent reply	other threads:[~2013-12-20 22:21 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-20 22:21 [Qemu-devel] [PATCH v3 0/5] Monitor commands for object-add/del Paolo Bonzini
2013-12-20 22:21 ` [Qemu-devel] [PATCH v3 1/5] rng: initialize file descriptor to -1 Paolo Bonzini
2013-12-20 22:21 ` Paolo Bonzini [this message]
2013-12-20 22:21 ` [Qemu-devel] [PATCH v3 3/5] qom: catch errors in object_property_add_child Paolo Bonzini
2013-12-20 22:21 ` [Qemu-devel] [PATCH v3 4/5] monitor: add object-del (QMP) and object_del (HMP) command Paolo Bonzini
2013-12-20 22:21 ` [Qemu-devel] [PATCH v3 5/5] monitor: add object-add (QMP) and object_add " Paolo Bonzini
2014-01-03 14:17 ` [Qemu-devel] [PATCH v3 0/5] Monitor commands for object-add/del Igor Mammedov
2014-01-03 14:24 ` Igor Mammedov
2014-01-03 14:41   ` Luiz Capitulino
2014-01-06 18:53 ` Luiz Capitulino

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1387578070-2884-3-git-send-email-pbonzini@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=afaerber@suse.de \
    --cc=imammedo@redhat.com \
    --cc=lcapitulino@xilinx.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).