From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56671) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bIs7k-0003bK-3f for qemu-devel@nongnu.org; Fri, 01 Jul 2016 02:40:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bIs7i-0003It-28 for qemu-devel@nongnu.org; Fri, 01 Jul 2016 02:40:23 -0400 From: David Gibson Date: Fri, 1 Jul 2016 16:41:56 +1000 Message-Id: <1467355319-28406-21-git-send-email-david@gibson.dropbear.id.au> In-Reply-To: <1467355319-28406-1-git-send-email-david@gibson.dropbear.id.au> References: <1467355319-28406-1-git-send-email-david@gibson.dropbear.id.au> Subject: [Qemu-devel] [PULL 20/23] spapr: drop reference on child object during core realization List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: peter.maydell@linaro.org Cc: agraf@suse.de, benh@kernel.crashing.org, qemu-devel@nongnu.org, qemu-ppc@nongnu.org, Greg Kurz , David Gibson From: Greg Kurz When a core is being realized, we create a child object for each thread of the core. The child is first initialized with object_initialize() which sets its ref count to 1, and then added to the core with object_property_add_child() which bumps the ref count to 2. When the core gets released, object_unparent() decreases the ref count to 1, and we g_free() the object: we hence loose the reference on an unfinalized object. This is likely to cause random crashes. Let's drop the extra reference as soon as we don't need it, after the thread is added to the core. Signed-off-by: Greg Kurz Reviewed-by: Bharata B Rao Signed-off-by: David Gibson --- hw/ppc/spapr_cpu_core.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c index e30b159..bba3612 100644 --- a/hw/ppc/spapr_cpu_core.c +++ b/hw/ppc/spapr_cpu_core.c @@ -300,6 +300,7 @@ static void spapr_cpu_core_realize(DeviceState *dev, Error **errp) if (local_err) { goto err; } + object_unref(obj); } object_child_foreach(OBJECT(dev), spapr_cpu_core_realize_child, &local_err); if (local_err) { -- 2.7.4