qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@redhat.com>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
	Anthony Liguori <aliguori@amazon.com>,
	Stefan Hajnoczi <stefanha@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Andreas Faerber <afaerber@suse.de>,
	KONRAD Frederic <fred.konrad@greensocs.com>
Subject: [Qemu-devel] [PATCH v2 4/4] virtio-rng: avoid default_backend refcount leak
Date: Wed,  5 Mar 2014 10:40:28 +0100	[thread overview]
Message-ID: <1394012428-11678-5-git-send-email-stefanha@redhat.com> (raw)
In-Reply-To: <1394012428-11678-1-git-send-email-stefanha@redhat.com>

QOM child properties take a reference to the object and release it when
the property is deleted.  Therefore we should unref the default_backend
after we have added it as a child property.

Cc: KONRAD Frederic <fred.konrad@greensocs.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 hw/virtio/virtio-rng.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/hw/virtio/virtio-rng.c b/hw/virtio/virtio-rng.c
index 8efe0aa..ddba756 100644
--- a/hw/virtio/virtio-rng.c
+++ b/hw/virtio/virtio-rng.c
@@ -162,6 +162,9 @@ static void virtio_rng_device_realize(DeviceState *dev, Error **errp)
                                   OBJECT(vrng->conf.default_backend),
                                   NULL);
 
+        /* The child property took a reference, we can safely drop ours now */
+        object_unref(OBJECT(vrng->conf.default_backend));
+
         object_property_set_link(OBJECT(dev),
                                  OBJECT(vrng->conf.default_backend),
                                  "rng", NULL);
-- 
1.8.5.3

  parent reply	other threads:[~2014-03-05  9:41 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-05  9:40 [Qemu-devel] [PATCH v2 0/4] qom: link property fixes Stefan Hajnoczi
2014-03-05  9:40 ` [Qemu-devel] [PATCH v2 1/4] qom: split object_property_set_link() Stefan Hajnoczi
2014-03-05  9:40 ` [Qemu-devel] [PATCH v2 2/4] qom: make QOM link property unref optional Stefan Hajnoczi
2014-03-05  9:40 ` [Qemu-devel] [PATCH v2 3/4] qom: add set() argument to object_property_add_link() Stefan Hajnoczi
2014-03-05  9:40 ` Stefan Hajnoczi [this message]
2014-03-05 13:29 ` [Qemu-devel] [PATCH v2 0/4] qom: link property fixes Stefan Hajnoczi

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=1394012428-11678-5-git-send-email-stefanha@redhat.com \
    --to=stefanha@redhat.com \
    --cc=afaerber@suse.de \
    --cc=aliguori@amazon.com \
    --cc=fred.konrad@greensocs.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --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).