From patchwork Tue Mar 4 21:45:12 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 326518 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 89E592C0097 for ; Wed, 5 Mar 2014 08:47:42 +1100 (EST) Received: from localhost ([::1]:48731 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WKxBc-0001h7-5Z for incoming@patchwork.ozlabs.org; Tue, 04 Mar 2014 16:47:40 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44709) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WKxAX-0000QO-4i for qemu-devel@nongnu.org; Tue, 04 Mar 2014 16:46:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WKxAS-0002AH-Ez for qemu-devel@nongnu.org; Tue, 04 Mar 2014 16:46:33 -0500 Received: from mx1.redhat.com ([209.132.183.28]:7580) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WKxAS-0002AA-7O for qemu-devel@nongnu.org; Tue, 04 Mar 2014 16:46:28 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s24LjPEB029761 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 4 Mar 2014 16:45:25 -0500 Received: from localhost (ovpn-112-46.ams2.redhat.com [10.36.112.46]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s24LjOUa003917; Tue, 4 Mar 2014 16:45:24 -0500 From: Stefan Hajnoczi To: Date: Tue, 4 Mar 2014 22:45:12 +0100 Message-Id: <1393969512-9468-5-git-send-email-stefanha@redhat.com> In-Reply-To: <1393969512-9468-1-git-send-email-stefanha@redhat.com> References: <1393969512-9468-1-git-send-email-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Peter Maydell , Andreas Faerber , Anthony Liguori , Paolo Bonzini Subject: [Qemu-devel] [PATCH 4/4] virtio-rng: avoid default_backend refcount leak X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 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);