@@ -1930,7 +1930,7 @@ static void __init ppc4xx_pciex_port_setup_hose(struct ppc4xx_pciex_port *port)
/* Allocate the host controller data structure */
hose = pcibios_alloc_controller(port->node);
if (!hose)
- goto fail;
+ return;
/* We stick the port number in "indirect_type" so the config space
* ops can retrieve the port data structure easily
@@ -1962,7 +1962,7 @@ static void __init ppc4xx_pciex_port_setup_hose(struct ppc4xx_pciex_port *port)
if (cfg_data == NULL) {
printk(KERN_ERR "%pOF: Can't map external config space !",
port->node);
- goto fail;
+ goto free_controller;
}
hose->cfg_data = cfg_data;
}
@@ -1974,7 +1974,7 @@ static void __init ppc4xx_pciex_port_setup_hose(struct ppc4xx_pciex_port *port)
if (mbase == NULL) {
printk(KERN_ERR "%pOF: Can't map internal config space !",
port->node);
- goto fail;
+ goto recheck_cfg_data;
}
hose->cfg_addr = mbase;
@@ -2007,7 +2007,7 @@ static void __init ppc4xx_pciex_port_setup_hose(struct ppc4xx_pciex_port *port)
/* Parse inbound mapping resources */
if (ppc4xx_parse_dma_ranges(hose, mbase, &dma_window) != 0)
- goto fail;
+ goto unmap_io_mbase;
/* Configure outbound ranges POMs */
ppc4xx_configure_pciex_POMs(port, hose, mbase);
@@ -2064,13 +2064,14 @@ static void __init ppc4xx_pciex_port_setup_hose(struct ppc4xx_pciex_port *port)
}
return;
- fail:
- if (hose)
- pcibios_free_controller(hose);
+
+unmap_io_mbase:
+ iounmap(mbase);
+recheck_cfg_data:
if (cfg_data)
iounmap(cfg_data);
- if (mbase)
- iounmap(mbase);
+free_controller:
+ pcibios_free_controller(hose);
}
static void __init ppc4xx_probe_pciex_bridge(struct device_node *np)
Date: Thu, 16 Mar 2023 19:00:57 +0100 The label “fail” was used to jump to another pointer check despite of the detail in the implementation of the function “ppc4xx_pciex_port_setup_hose” that it was determined already that the corresponding variable contained a null pointer (because of a failed function call in three cases). 1. Thus return directly after a call of the function “pcibios_alloc_controller” failed. 2. Use more appropriate labels instead. 3. Reorder jump targets at the end. 4. Delete two questionable checks. This issue was detected by using the Coccinelle software. Fixes: a2d2e1ec07a80946cbe812dc8c73291cad8214b2 ("[POWERPC] 4xx: PLB to PCI Express support") Fixes: 80daac3f86d4f5aafc9d3e79addb90fa118244e2 ("[POWERPC] 4xx: Add endpoint support to 4xx PCIe driver") Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> --- arch/powerpc/platforms/4xx/pci.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) -- 2.40.0