Skip to contentSkip to conversation

PCI: stm32: clean up some error handling in probe()

PATCH In review Dan Carpenter 2 participants 2 messages Sep 5, 2025

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 PCI: stm32: clean up some error handling in probe()

Smatch complains that the other error paths use gotos to clean up and these two don't. Generally, the implication with that warning is that the error handly has been ommitted. In this case, the error handling is fine, but we can avoid a bit of code duplication by using gotos to clean up.

---
 drivers/pci/controller/dwc/pcie-stm32.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/pci/controller/dwc/pcie-stm32.c +4 -6
index 964fa6f674c8..96a5fb893af4 100644
@@ -287,18 +287,16 @@ static int stm32_pcie_probe(struct platform_device *pdev)
 
 	ret = pm_runtime_set_active(dev);
 	if (ret < 0) {
-		clk_disable_unprepare(stm32_pcie->clk);
-		stm32_remove_pcie_port(stm32_pcie);
-		return dev_err_probe(dev, ret, "Failed to activate runtime PM\n");
+		dev_err_probe(dev, ret, "Failed to activate runtime PM\n");
+		goto err_disable_clk;
 	}
 
 	pm_runtime_no_callbacks(dev);
 
 	ret = devm_pm_runtime_enable(dev);
 	if (ret < 0) {
-		clk_disable_unprepare(stm32_pcie->clk);
-		stm32_remove_pcie_port(stm32_pcie);
-		return dev_err_probe(dev, ret, "Failed to enable runtime PM\n");
+		dev_err_probe(dev, ret, "Failed to enable runtime PM\n");
+		goto err_disable_clk;
 	}
 
 	ret = dw_pcie_host_init(&stm32_pcie->pci.pp);
Signature · 1 line
2.47.2
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 28 lines · Dan Carpenter

Smatch complains that the other error paths use gotos to clean up and these two don't. Generally, the implication with that warning is that the error handly has been ommitted. In this case, the error handling is fine, but we can avoid a bit of code duplication by using gotos to clean up.

---
  drivers/pci/controller/dwc/pcie-stm32.c | 10 ++++------
  1 file changed, 4 insertions(+), 6 deletions(-)
drivers/pci/controller/dwc/pcie-stm32.c +2 -3
index 964fa6f674c8..96a5fb893af4 100644
@@ -287,18 +287,16 @@ static int stm32_pcie_probe(struct platform_device *pdev)
 
  	ret = pm_runtime_set_active(dev);
  	if (ret < 0) {
-		clk_disable_unprepare(stm32_pcie->clk);
-		stm32_remove_pcie_port(stm32_pcie);
-		return dev_err_probe(dev, ret, "Failed to activate runtime PM\n");
+		dev_err_probe(dev, ret, "Failed to activate runtime PM\n");
+		goto err_disable_clk;
  	}
 
  	pm_runtime_no_callbacks(dev);
 

drivers/pci/controller/dwc/pcie-stm32.c static int stm32_pcie_probe(struct platform_device *pdev) · line 302

Quoted 10 lines
drivers/pci/controller/dwc/pcie-stm32.c +2 -3
  	ret = devm_pm_runtime_enable(dev);
  	if (ret < 0) {
-		clk_disable_unprepare(stm32_pcie->clk);
-		stm32_remove_pcie_port(stm32_pcie);
-		return dev_err_probe(dev, ret, "Failed to enable runtime PM\n");
+		dev_err_probe(dev, ret, "Failed to enable runtime PM\n");
+		goto err_disable_clk;
  	}
 
  	ret = dw_pcie_host_init(&stm32_pcie->pci.pp);

thank you

Christian