From nobody Tue Feb 10 19:14:41 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1507194560365782.349642914741; Thu, 5 Oct 2017 02:09:20 -0700 (PDT) Received: from localhost ([::1]:38530 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e029a-0001du-Lw for importer@patchew.org; Thu, 05 Oct 2017 05:09:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53001) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e025P-0007Kv-23 for qemu-devel@nongnu.org; Thu, 05 Oct 2017 05:05:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e025J-00048V-21 for qemu-devel@nongnu.org; Thu, 05 Oct 2017 05:04:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52666) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e025I-00047d-PT for qemu-devel@nongnu.org; Thu, 05 Oct 2017 05:04:48 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D63E072FFB for ; Thu, 5 Oct 2017 09:04:47 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-239.ams2.redhat.com [10.36.116.239]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7E2165FCCB; Thu, 5 Oct 2017 09:04:44 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 1C5ED4057A; Thu, 5 Oct 2017 11:04:43 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D63E072FFB Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=kraxel@redhat.com From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Thu, 5 Oct 2017 11:04:40 +0200 Message-Id: <20171005090443.26889-2-kraxel@redhat.com> In-Reply-To: <20171005090443.26889-1-kraxel@redhat.com> References: <20171005090443.26889-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 05 Oct 2017 09:04:47 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 1/4] hw/usb/bus: Remove bad object_unparent() from usb_try_create_simple() 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: Thomas Huth , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Thomas Huth Valgrind detects an invalid read operation when hot-plugging of an USB device fails: $ valgrind x86_64-softmmu/qemu-system-x86_64 -device usb-ehci -nographic -S =3D=3D30598=3D=3D Memcheck, a memory error detector =3D=3D30598=3D=3D Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward = et al. =3D=3D30598=3D=3D Using Valgrind-3.12.0 and LibVEX; rerun with -h for copyr= ight info =3D=3D30598=3D=3D Command: x86_64-softmmu/qemu-system-x86_64 -device usb-eh= ci -nographic -S =3D=3D30598=3D=3D QEMU 2.10.50 monitor - type 'help' for more information (qemu) device_add usb-tablet (qemu) device_add usb-tablet (qemu) device_add usb-tablet (qemu) device_add usb-tablet (qemu) device_add usb-tablet (qemu) device_add usb-tablet =3D=3D30598=3D=3D Invalid read of size 8 =3D=3D30598=3D=3D at 0x60EF50: object_unparent (object.c:445) =3D=3D30598=3D=3D by 0x580F0D: usb_try_create_simple (bus.c:346) =3D=3D30598=3D=3D by 0x581BEB: usb_claim_port (bus.c:451) =3D=3D30598=3D=3D by 0x582310: usb_qdev_realize (bus.c:257) =3D=3D30598=3D=3D by 0x4CB399: device_set_realized (qdev.c:914) =3D=3D30598=3D=3D by 0x60E26D: property_set_bool (object.c:1886) =3D=3D30598=3D=3D by 0x61235E: object_property_set_qobject (qom-qobject.= c:27) =3D=3D30598=3D=3D by 0x61000F: object_property_set_bool (object.c:1162) =3D=3D30598=3D=3D by 0x4567C3: qdev_device_add (qdev-monitor.c:630) =3D=3D30598=3D=3D by 0x456D52: qmp_device_add (qdev-monitor.c:807) =3D=3D30598=3D=3D by 0x470A99: hmp_device_add (hmp.c:1933) =3D=3D30598=3D=3D by 0x3679C3: handle_hmp_command (monitor.c:3123) The object_unparent() here is not necessary anymore since commit 69382d8b3e8600b3 ("qdev: Fix object reference leak in case device.realize() fails"), so let's remove it now. Suggested-by: Paolo Bonzini Signed-off-by: Thomas Huth Message-id: 1506526106-30971-1-git-send-email-thuth@redhat.com Signed-off-by: Gerd Hoffmann --- hw/usb/bus.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/hw/usb/bus.c b/hw/usb/bus.c index d910f849e7..e56dc3348a 100644 --- a/hw/usb/bus.c +++ b/hw/usb/bus.c @@ -341,9 +341,7 @@ static USBDevice *usb_try_create_simple(USBBus *bus, co= nst char *name, object_property_set_bool(OBJECT(dev), true, "realized", &err); if (err) { error_propagate(errp, err); - error_prepend(errp, "Failed to initialize USB device '%s': ", - name); - object_unparent(OBJECT(dev)); + error_prepend(errp, "Failed to initialize USB device '%s': ", name= ); return NULL; } return dev; --=20 2.9.3