Skip to contentSkip to conversation

PCI: mt7621: Release port reset controls on host registration failure

PATCH In review Yige Jiang 3 participants 3 messages Dec 3

Subsystems (5)
lore
Share & tools
lore

Yige Jiang

author
#0 lore raw

PATCH v2 1/1 PCI: mt7621: Release port reset controls on host registration failure

mt7621_pcie_parse_port() takes an exclusive reset control for each root port. If pci_host_probe() fails, mt7621_pcie_probe() returns the error from mt7621_pcie_register_host() without releasing the reset controls for the ports on pcie->ports. A subsequent probe can then fail to acquire those controls.

Use the existing remove_resets path on host registration failure to release the controls and return the original error.

Fixes 2bdd5238e756 ("PCI: mt7621: Add MediaTek MT7621 PCIe host controller driver")

---
Changes in v2:
- Drop the change to the device tree parsing error path, as requested by Sergio Paracuellos.

v1: https://lore.kernel.org/r/[email protected]/
Review: https://lore.kernel.org/r/CAMhs-H_Yd4L9jyYvH+BJy5BDSPO8AQy6X5vFFaR50eqS_UxAkw@mail.gmail.com/

 drivers/pci/controller/pcie-mt7621.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/pci/controller/pcie-mt7621.c +5 -1
index 79f973f8a605..9ee0961ef050 100644
@@ -510,7 +510,11 @@ static int mt7621_pcie_probe(struct platform_device *pdev)
 		goto remove_resets;
 	}
 
-	return mt7621_pcie_register_host(bridge);
+	err = mt7621_pcie_register_host(bridge);
+	if (err)
+		goto remove_resets;
+
+	return 0;
 
 remove_resets:
 	list_for_each_entry(port, &pcie->ports, list)

base-commit: 630059a5a632377b9b7b487baccde92b7ae1dd47

maintainer Reviewed-by on v2 1/1
#1 lore raw
Quoted 18 lines · Yige Jiang

mt7621_pcie_parse_port() takes an exclusive reset control for each root port. If pci_host_probe() fails, mt7621_pcie_probe() returns the error from mt7621_pcie_register_host() without releasing the reset controls for the ports on pcie->ports. A subsequent probe can then fail to acquire those controls.

Use the existing remove_resets path on host registration failure to release the controls and return the original error.

Fixes 2bdd5238e756 ("PCI: mt7621: Add MediaTek MT7621 PCIe host controller driver")

---
Changes in v2:
- Drop the change to the device tree parsing error path, as requested by Sergio Paracuellos.

Quoted 5 lines

v1: https://lore.kernel.org/r/[email protected]/
Review: https://lore.kernel.org/r/CAMhs-H_Yd4L9jyYvH+BJy5BDSPO8AQy6X5vFFaR50eqS_UxAkw@mail.gmail.com/

 drivers/pci/controller/pcie-mt7621.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Thanks,
Sergio Paracuellos

#2 lore raw
In reply to Yige Jiang
Sashiko has reviewed this patch and found no issues.
Quoted 6 lines

mt7621_pcie_parse_port() takes an exclusive reset control for each root port. If pci_host_probe() fails, mt7621_pcie_probe() returns the error from mt7621_pcie_register_host() without releasing the reset controls for the ports on pcie->ports. A subsequent probe can then fail to acquire those controls.

Quoted 6 lines

Use the existing remove_resets path on host registration failure to release the controls and return the original error.

Fixes 2bdd5238e756 ("PCI: mt7621: Add MediaTek MT7621 PCIe host controller driver")

Sashiko has reviewed this patch and found no issues.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1