From nobody Fri Nov 14 13:37:54 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1587756083; cv=none; d=zohomail.com; s=zohoarc; b=n8OI+IEmr3VB3OK6utDfiEhNzqac7z0KUQlyDh5FcL/eQ96HBALqvViN62jUG8lXg1OC57HQrVOlQ43WJpGfWJ0PtirtJj421BzkFeV6kxA38J2geFlHY/WkGBe66B5SrdVPBW9ULFhR6K4soN5Q2jKys5Muue/CtvZ8HCWWKsE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1587756083; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=JCs/MUWiOabJCVAQ8sLvUQgrb8weKuUkchaXXg61HdM=; b=hXLt5GFruble5FQpNHgDOyra3r5A73PNsLS2IDMmIxD54If5FCEmXOv9Bhbxfj/gCAmQYxfs5U97Oddq7NzRllf89RWJsHEl9SYhpHPnBHcI05ui7QWAnmebvmOpZV8xJ2evbR3aVQktT4obbFrkZVU10yrH0m4ZAh7iZxJXa/Q= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1587756083492184.61936789138292; Fri, 24 Apr 2020 12:21:23 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jS3sP-0006d6-HZ; Fri, 24 Apr 2020 19:20:41 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jS3sO-0006d1-TO for xen-devel@lists.xenproject.org; Fri, 24 Apr 2020 19:20:40 +0000 Received: from us-smtp-delivery-1.mimecast.com (unknown [207.211.31.120]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id af1ae10e-8660-11ea-94ff-12813bfff9fa; Fri, 24 Apr 2020 19:20:40 +0000 (UTC) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-493-0hfApBy5PNeX1QqpGuxL5A-1; Fri, 24 Apr 2020 15:20:35 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7E07684B8A0; Fri, 24 Apr 2020 19:20:32 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-113-6.ams2.redhat.com [10.36.113.6]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 742121A925; Fri, 24 Apr 2020 19:20:29 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 2DB3011358BE; Fri, 24 Apr 2020 21:20:27 +0200 (CEST) X-Inumbo-ID: af1ae10e-8660-11ea-94ff-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587756039; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JCs/MUWiOabJCVAQ8sLvUQgrb8weKuUkchaXXg61HdM=; b=HfiW4QbjHna2jbBAEL2OUiajy2BviIqCw8Ci9M3+QkY2B7wWb0oqvuk8lXi7DUB0w3PRWz YRhrCqZsh8+Z1s54i4uxcwsbP13thJdcCdyQvWiSH8i92Fmlb46kdugMpgVIWkLAReiHGS q1Iik1A9T97qEUeBlwrvI2fB0yccwmg= X-MC-Unique: 0hfApBy5PNeX1QqpGuxL5A-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 02/11] xen: Fix and improve handling of device_add usb-host errors Date: Fri, 24 Apr 2020 21:20:18 +0200 Message-Id: <20200424192027.11404-3-armbru@redhat.com> In-Reply-To: <20200424192027.11404-1-armbru@redhat.com> References: <20200424192027.11404-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Anthony Perard , xen-devel@lists.xenproject.org, Stefano Stabellini , Gerd Hoffmann , Paul Durrant Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" usbback_portid_add() leaks the error when qdev_device_add() fails. Fix that. While there, use the error to improve the error message. The qemu_opts_from_qdict() similarly leaks on failure. But any failure there is a programming error. Pass &error_abort. Fixes: 816ac92ef769f9ffc534e49a1bb6177bddce7aa2 Cc: Stefano Stabellini Cc: Anthony Perard Cc: Paul Durrant Cc: Gerd Hoffmann Cc: xen-devel@lists.xenproject.org Signed-off-by: Markus Armbruster --- hw/usb/xen-usb.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/hw/usb/xen-usb.c b/hw/usb/xen-usb.c index 961190d0f7..42643c3390 100644 --- a/hw/usb/xen-usb.c +++ b/hw/usb/xen-usb.c @@ -30,6 +30,7 @@ #include "hw/usb.h" #include "hw/xen/xen-legacy-backend.h" #include "monitor/qdev.h" +#include "qapi/error.h" #include "qapi/qmp/qdict.h" #include "qapi/qmp/qstring.h" =20 @@ -755,13 +756,15 @@ static void usbback_portid_add(struct usbback_info *u= sbif, unsigned port, qdict_put_int(qdict, "port", port); qdict_put_int(qdict, "hostbus", atoi(busid)); qdict_put_str(qdict, "hostport", portname); - opts =3D qemu_opts_from_qdict(qemu_find_opts("device"), qdict, &local_= err); - if (local_err) { - goto err; - } + opts =3D qemu_opts_from_qdict(qemu_find_opts("device"), qdict, + &error_abort); usbif->ports[port - 1].dev =3D USB_DEVICE(qdev_device_add(opts, &local= _err)); if (!usbif->ports[port - 1].dev) { - goto err; + qobject_unref(qdict); + xen_pv_printf(&usbif->xendev, 0, + "device %s could not be opened: %s\n", + busid, error_get_pretty(local_err)); + error_free(local_err); } qobject_unref(qdict); speed =3D usbif->ports[port - 1].dev->speed; @@ -793,11 +796,6 @@ static void usbback_portid_add(struct usbback_info *us= bif, unsigned port, usbback_hotplug_enq(usbif, port); =20 TR_BUS(&usbif->xendev, "port %d attached\n", port); - return; - -err: - qobject_unref(qdict); - xen_pv_printf(&usbif->xendev, 0, "device %s could not be opened\n", bu= sid); } =20 static void usbback_process_port(struct usbback_info *usbif, unsigned port) --=20 2.21.1