Received: from eggs.gnu.org ([2001:4830:134:3::10]:33924) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ceNiS-0000ko-5o for qemu-devel@nongnu.org; Thu, 16 Feb 2017 10:11:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ceNiM-0007re-Hg for qemu-devel@nongnu.org; Thu, 16 Feb 2017 10:11:28 -0500 Date: Thu, 16 Feb 2017 16:11:14 +0100 From: Igor Mammedov Message-ID: <20170216161114.220260cf@nial.brq.redhat.com> In-Reply-To: References: <1487253461-269218-1-git-send-email-imammedo@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] hw/arm/virt: fix cpu object reference leak List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: Andrew Jones , qemu-arm , QEMU Developers On Thu, 16 Feb 2017 14:18:05 +0000 Peter Maydell wrote: > On 16 February 2017 at 13:57, Igor Mammedov wrote: > > object_new(FOO) returns an object with ref_cnt == 1 > > and following > > object_property_set_bool(cpuobj, true, "realized", NULL) > > set parent of cpuobj to '/machine/unattached' which makes > > ref_cnt == 2. > > > > Since machvirt_init() doesn't take ownership of cpuobj > > returned by object_new() it should explicitly drop > > reference to cpuobj when dangling pointer is about to > > go out of scope like it's done pc_new_cpu() to avoid > > object leak. > > I've always found the object reference semantics somewhat > confusing (why does realizing a device add a reference, > for instance?). Do we document them anywhere? I'm not aware of a place where it's documented. currently device_realize() sets parent thus increasing ref counter only if device creator haven't set parent explicitly. > > thanks > -- PMM >