From patchwork Mon Jul 16 12:59:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Huth X-Patchwork-Id: 944391 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com 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 41TkGy1nlGz9rxs for ; Mon, 16 Jul 2018 23:07:52 +1000 (AEST) Received: from localhost ([::1]:51287 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ff3E8-0006gN-Ra for incoming@patchwork.ozlabs.org; Mon, 16 Jul 2018 09:07:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43497) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ff36Z-0001G9-SW for qemu-devel@nongnu.org; Mon, 16 Jul 2018 08:59:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ff36Y-00028G-Tl for qemu-devel@nongnu.org; Mon, 16 Jul 2018 08:59:55 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:38014 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ff36S-00024R-Iz; Mon, 16 Jul 2018 08:59:48 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EA55341C1B; Mon, 16 Jul 2018 12:59:47 +0000 (UTC) Received: from thh440s.str.redhat.com (dhcp-200-180.str.redhat.com [10.33.200.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id 73D5B1C589; Mon, 16 Jul 2018 12:59:46 +0000 (UTC) From: Thomas Huth To: qemu-devel@nongnu.org, Peter Maydell , Paolo Bonzini Date: Mon, 16 Jul 2018 14:59:23 +0200 Message-Id: <1531745974-17187-7-git-send-email-thuth@redhat.com> In-Reply-To: <1531745974-17187-1-git-send-email-thuth@redhat.com> References: <1531745974-17187-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Mon, 16 Jul 2018 12:59:48 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Mon, 16 Jul 2018 12:59:48 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'thuth@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH v3 06/17] hw/arm/msf2-soc: Fix introspection problem with the "msf2-soc" device X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , Alistair Francis , Markus Armbruster , Subbaraya Sundeep , Beniamino Galvani , qemu-arm@nongnu.org, "Edgar E. Iglesias" , =?utf-8?q?Andreas_F?= =?utf-8?b?w6RyYmVy?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Valgrind currently reports a problem when running QEMU like this: echo "{'execute':'qmp_capabilities'} {'execute':'device-list-properties'," \ "'arguments':{'typename':'msf2-soc'}}" \ "{'execute': 'human-monitor-command', " \ "'arguments': {'command-line': 'info qtree'}}" | \ valgrind -q aarch64-softmmu/qemu-system-aarch64 -M none,accel=qtest -qmp stdio [...] ==23097== Invalid read of size 8 ==23097== at 0x6192AA: qdev_print (qdev-monitor.c:686) ==23097== by 0x6192AA: qbus_print (qdev-monitor.c:719) [...] Use the new sysbus_init_child_obj() function to make sure that the child objects are cleaned up correctly when the parent gets destroyed. Reviewed-by: Richard Henderson Reviewed-by: Paolo Bonzini Reviewed-by: Eduardo Habkost Signed-off-by: Thomas Huth --- hw/arm/msf2-soc.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/hw/arm/msf2-soc.c b/hw/arm/msf2-soc.c index edb3ba8..dbefade 100644 --- a/hw/arm/msf2-soc.c +++ b/hw/arm/msf2-soc.c @@ -68,19 +68,18 @@ static void m2sxxx_soc_initfn(Object *obj) MSF2State *s = MSF2_SOC(obj); int i; - object_initialize(&s->armv7m, sizeof(s->armv7m), TYPE_ARMV7M); - qdev_set_parent_bus(DEVICE(&s->armv7m), sysbus_get_default()); + sysbus_init_child_obj(obj, "armv7m", &s->armv7m, sizeof(s->armv7m), + TYPE_ARMV7M); - object_initialize(&s->sysreg, sizeof(s->sysreg), TYPE_MSF2_SYSREG); - qdev_set_parent_bus(DEVICE(&s->sysreg), sysbus_get_default()); + sysbus_init_child_obj(obj, "sysreg", &s->sysreg, sizeof(s->sysreg), + TYPE_MSF2_SYSREG); - object_initialize(&s->timer, sizeof(s->timer), TYPE_MSS_TIMER); - qdev_set_parent_bus(DEVICE(&s->timer), sysbus_get_default()); + sysbus_init_child_obj(obj, "timer", &s->timer, sizeof(s->timer), + TYPE_MSS_TIMER); for (i = 0; i < MSF2_NUM_SPIS; i++) { - object_initialize(&s->spi[i], sizeof(s->spi[i]), + sysbus_init_child_obj(obj, "spi[*]", &s->spi[i], sizeof(s->spi[i]), TYPE_MSS_SPI); - qdev_set_parent_bus(DEVICE(&s->spi[i]), sysbus_get_default()); } }