Skip to content

Commit b52fa0e

Browse files
philmdmstsirkin
authored andcommitted
hw/pci: Have safer pcie_bus_realize() by checking error path
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 <[email protected]> Signed-off-by: Philippe Mathieu-Daudé <[email protected]> Message-Id: <[email protected]> Reviewed-by: Michael S. Tsirkin <[email protected]> Signed-off-by: Michael S. Tsirkin <[email protected]>
1 parent fb59288 commit b52fa0e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

hw/pci/pci.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,13 @@ static void pci_bus_realize(BusState *qbus, Error **errp)
132132
static void pcie_bus_realize(BusState *qbus, Error **errp)
133133
{
134134
PCIBus *bus = PCI_BUS(qbus);
135+
Error *local_err = NULL;
135136

136-
pci_bus_realize(qbus, errp);
137+
pci_bus_realize(qbus, &local_err);
138+
if (local_err) {
139+
error_propagate(errp, local_err);
140+
return;
141+
}
137142

138143
/*
139144
* A PCI-E bus can support extended config space if it's the root

0 commit comments

Comments
 (0)