Skip to content

Commit 5d18d70

Browse files
paliLorenzo Pieralisi
authored andcommitted
PCI: mvebu: Check for errors from pci_bridge_emul_init() call
Function pci_bridge_emul_init() may fail so correctly check for errors. Link: https://lore.kernel.org/r/20211125124605.25915-3-pali@kernel.org Fixes: 1f08673 ("PCI: mvebu: Convert to PCI emulated bridge config space") Signed-off-by: Pali Rohár <pali@kernel.org> Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
1 parent 8cdabfd commit 5d18d70

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

drivers/pci/controller/pci-mvebu.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@ static struct pci_bridge_emul_ops mvebu_pci_bridge_emul_ops = {
570570
* Initialize the configuration space of the PCI-to-PCI bridge
571571
* associated with the given PCIe interface.
572572
*/
573-
static void mvebu_pci_bridge_emul_init(struct mvebu_pcie_port *port)
573+
static int mvebu_pci_bridge_emul_init(struct mvebu_pcie_port *port)
574574
{
575575
struct pci_bridge_emul *bridge = &port->bridge;
576576

@@ -589,7 +589,7 @@ static void mvebu_pci_bridge_emul_init(struct mvebu_pcie_port *port)
589589
bridge->data = port;
590590
bridge->ops = &mvebu_pci_bridge_emul_ops;
591591

592-
pci_bridge_emul_init(bridge, PCI_BRIDGE_EMUL_NO_PREFETCHABLE_BAR);
592+
return pci_bridge_emul_init(bridge, PCI_BRIDGE_EMUL_NO_PREFETCHABLE_BAR);
593593
}
594594

595595
static inline struct mvebu_pcie *sys_to_pcie(struct pci_sys_data *sys)
@@ -1075,9 +1075,18 @@ static int mvebu_pcie_probe(struct platform_device *pdev)
10751075
continue;
10761076
}
10771077

1078+
ret = mvebu_pci_bridge_emul_init(port);
1079+
if (ret < 0) {
1080+
dev_err(dev, "%s: cannot init emulated bridge\n",
1081+
port->name);
1082+
devm_iounmap(dev, port->base);
1083+
port->base = NULL;
1084+
mvebu_pcie_powerdown(port);
1085+
continue;
1086+
}
1087+
10781088
mvebu_pcie_setup_hw(port);
10791089
mvebu_pcie_set_local_dev_nr(port, 1);
1080-
mvebu_pci_bridge_emul_init(port);
10811090
}
10821091

10831092
pcie->nports = i;

0 commit comments

Comments
 (0)