From nobody Sun Oct 26 01:38:41 2025 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 1516079242659901.7926034493527; Mon, 15 Jan 2018 21:07:22 -0800 (PST) Received: from localhost ([::1]:35415 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ebJSz-0007r5-Ja for importer@patchew.org; Tue, 16 Jan 2018 00:07:21 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47983) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ebJ9m-00081y-EP for qemu-devel@nongnu.org; Mon, 15 Jan 2018 23:47:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ebJ9k-0004nu-8K for qemu-devel@nongnu.org; Mon, 15 Jan 2018 23:47:30 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60590) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ebJ9k-0004na-2K for qemu-devel@nongnu.org; Mon, 15 Jan 2018 23:47:28 -0500 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 24510C0587CA; Tue, 16 Jan 2018 04:47:27 +0000 (UTC) Received: from redhat.com (ovpn-125-221.rdu2.redhat.com [10.10.125.221]) by smtp.corp.redhat.com (Postfix) with SMTP id 95A768E789; Tue, 16 Jan 2018 04:47:26 +0000 (UTC) Date: Tue, 16 Jan 2018 06:47:26 +0200 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Message-ID: <1516077852-7974-14-git-send-email-mst@redhat.com> References: <1516077852-7974-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1516077852-7974-1-git-send-email-mst@redhat.com> X-Mutt-Fcc: =sent 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.32]); Tue, 16 Jan 2018 04:47:27 +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 13/33] hw/pci-bridge: fix QEMU crash because of pcie-root-port 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: Marcel Apfelbaum , Peter Maydell 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 Content-Type: text/plain; charset="utf-8" From: Marcel Apfelbaum If we try to use more pcie_root_ports then available slots and an IO hint is passed to the port, QEMU crashes because we try to init the "IO hint" capability even if the device is not created. Fix it by checking for error before adding the capability, so QEMU can fail gracefully. Signed-off-by: Marcel Apfelbaum Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/pci-bridge/gen_pcie_root_port.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/hw/pci-bridge/gen_pcie_root_port.c b/hw/pci-bridge/gen_pcie_ro= ot_port.c index ad4e6aa..0e2f2e8 100644 --- a/hw/pci-bridge/gen_pcie_root_port.c +++ b/hw/pci-bridge/gen_pcie_root_port.c @@ -74,8 +74,13 @@ static void gen_rp_realize(DeviceState *dev, Error **err= p) PCIDevice *d =3D PCI_DEVICE(dev); GenPCIERootPort *grp =3D GEN_PCIE_ROOT_PORT(d); PCIERootPortClass *rpc =3D PCIE_ROOT_PORT_GET_CLASS(d); + Error *local_err =3D NULL; =20 - rpc->parent_realize(dev, errp); + rpc->parent_realize(dev, &local_err); + if (local_err) { + error_propagate(errp, local_err); + return; + } =20 int rc =3D pci_bridge_qemu_reserve_cap_init(d, 0, grp->bus_reserve, grp->io_reserve, grp->mem_reserve, grp->pref32_reserve, --=20 MST