From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59427) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WLInf-0002V4-Q6 for qemu-devel@nongnu.org; Wed, 05 Mar 2014 15:52:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WLInb-0003d2-60 for qemu-devel@nongnu.org; Wed, 05 Mar 2014 15:52:23 -0500 Received: from mx1.redhat.com ([209.132.183.28]:59412) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WLIna-0003ct-Ta for qemu-devel@nongnu.org; Wed, 05 Mar 2014 15:52:19 -0500 From: Stefan Hajnoczi Date: Wed, 5 Mar 2014 21:51:24 +0100 Message-Id: <1394052684-14362-6-git-send-email-stefanha@redhat.com> In-Reply-To: <1394052684-14362-1-git-send-email-stefanha@redhat.com> References: <1394052684-14362-1-git-send-email-stefanha@redhat.com> Subject: [Qemu-devel] [PATCH v3 5/5] virtio-rng: avoid default_backend refcount leak List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Andreas Faerber , Anthony Liguori , Peter Maydell 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 Signed-off-by: Stefan Hajnoczi --- 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 cbf0138..b6ab361 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