From nobody Fri May 17 00:25:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1612193826; cv=none; d=zohomail.com; s=zohoarc; b=OytQWdSVoOr7z/TqerktgUMYyAK61q4iPAo9y3EVXyWulCF+e9YY+rEyOPFba4AE1/R8zsQ5vqTg596IPY+VsUGxAK4OVIX+tjin+2oJ/iX3ahW9wxTe6/5i+VvwvShnfiryrOmmYNrx9+kuhwOQsGMbQdkBAQea5tq2LcaNVFM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612193826; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:MIME-Version:Message-ID:Subject:To; bh=NiiPUtBQWDN924NgCHiXVlqTEUm0sOxUKiZegSkevc8=; b=TLb3juaLvZYeBXargdNkPYbqHA4hJga42REz9NtfYV6n+NSgmOennLdCzylykItCBrV8qQzdmPgu4/YgcYyW3sXUGw57ZgNitE5ZV7Zc0ecTRweir2ozWYFxDFmOKop97iN60JOxAsRclBTdecl2Uem1CtQ0aJYztOuHRBoxGQ8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1612193826666112.67290355471096; Mon, 1 Feb 2021 07:37:06 -0800 (PST) Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-364-d4N_AvEZNkGJH3P4ah6SHQ-1; Mon, 01 Feb 2021 10:37:04 -0500 Received: by mail-ed1-f70.google.com with SMTP id a26so8158429edx.8 for ; Mon, 01 Feb 2021 07:37:03 -0800 (PST) Return-Path: Return-Path: Received: from x1w.redhat.com (7.red-83-57-171.dynamicip.rima-tde.net. [83.57.171.7]) by smtp.gmail.com with ESMTPSA id i18sm8694276edt.68.2021.02.01.07.37.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Feb 2021 07:37:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612193825; 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; bh=NiiPUtBQWDN924NgCHiXVlqTEUm0sOxUKiZegSkevc8=; b=fH7jl0s3+dbArAkGdCCIHhX9pp8DMqGX8j5hasusKVS5Z8FJGW1CLIUZtfKRngXlXXj7g1 c+hZ7byDUzgmshyv816xfIWEegjodNmJ6udhPFtTHni8+DcZv7jt/ZFJ6EZXP6frKE4GRk PifeIdFLi4ykc27TilQe9jkc/8H44vg= X-MC-Unique: d4N_AvEZNkGJH3P4ah6SHQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=NiiPUtBQWDN924NgCHiXVlqTEUm0sOxUKiZegSkevc8=; b=U2unlJOZxuazfyU2pb7TJoN0l4nDKlOemKKtUXh8NbLbRlrap/7l+cuKQqEcNGk+fT RItnkoA1brC0iAXIv2X+07ajo0b55lzEMMboTEVpsPMmJYxPEZpQms3SW9XhElm+msfC AEm5KTl/JILdfVH8jxxx7Rt5VFeiNqMJ69sSFGWiyQxbSBr+eJaFtSRNZ+iX1p2RxOf+ Jc3PJrn26J0iCjene3G04lsOG1JxRAnccnReqMz7SLKKf3J333Q606K3Ai5h3r1P6tnb vFlaGRq09QhaZIqw3t8mJq/2hldU/uUkjW9X+6G3yqWn2fJRKG46QfzgovVGK3P/7WSj 2vNg== X-Gm-Message-State: AOAM532FPuXHUU3X0rYfmum2MV/V8kXqJY58dcmRJNLuqe/AGJWqJZxf v5eDmkGYgIQFWSBtrC3zbSFm48RDxqKMQFEyCey8AnAgeMQJ/M78StW/6PS7jQ9PtX/4+8WQUAx eq39q/J4IYj88rQ== X-Received: by 2002:a17:906:8617:: with SMTP id o23mr5994836ejx.289.1612193822778; Mon, 01 Feb 2021 07:37:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJyBhQARvhvSGmU091A6RhUM0w5GOuCNzGgufBftNqzbhuVuAN/9VyZ14eNGU7SxigHmr8r9fw== X-Received: by 2002:a17:906:8617:: with SMTP id o23mr5994822ejx.289.1612193822591; Mon, 01 Feb 2021 07:37:02 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Marcel Apfelbaum , "Michael S. Tsirkin" , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Markus Armbruster Subject: [PATCH] hw/pci: Have safer pcie_bus_realize() by checking error path Date: Mon, 1 Feb 2021 16:37:00 +0100 Message-Id: <20210201153700.618946-1-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) While pci_bus_realize() currently does not use the Error* argument, it would be an error to leave pcie_bus_realize() setting bus->flags if pci_bus_realize() had failed. Fix by using a local Error* and return early (propagating the error) if pci_bus_realize() failed. Reported-by: Markus Armbruster Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/pci/pci.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 512e9042ffa..0d12e94a02e 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -130,8 +130,13 @@ static void pci_bus_realize(BusState *qbus, Error **er= rp) static void pcie_bus_realize(BusState *qbus, Error **errp) { PCIBus *bus =3D PCI_BUS(qbus); + Error *local_err =3D NULL; =20 - pci_bus_realize(qbus, errp); + pci_bus_realize(qbus, &local_err); + if (local_err) { + error_propagate(errp, local_err); + return; + } =20 /* * A PCI-E bus can support extended config space if it's the root --=20 2.26.2