Skip to contentSkip to conversation

PCI: dra7xx: Added error handling in probe function when devm_phy_get() fails

PATCH Superseded Riyan Dhiman 2 participants 2 messages Sep 11, 2024 – Sep 20, 2024

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 PCI: dra7xx: Added error handling in probe function when devm_phy_get() fails

While creation of device link, if devm_phy_get() function fails then it directly returns PTR_ERR without any cleanup of previous added device links. Added goto statement when devm_phy_get() fails, to handle the cleanup of already added device links.

Fixes 7a4db656a635 (PCI: dra7xx: Create functional dependency between PCIe and PHY)
---
 drivers/pci/controller/dwc/pci-dra7xx.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/pci/controller/dwc/pci-dra7xx.c +4 -2
index 4fe3b0cb72ec..c329d107b811 100644
@@ -762,8 +762,10 @@ static int dra7xx_pcie_probe(struct platform_device *pdev)
 	for (i = 0; i < phy_count; i++) {
 		snprintf(name, sizeof(name), "pcie-phy%d", i);
 		phy[i] = devm_phy_get(dev, name);
-		if (IS_ERR(phy[i]))
-			return PTR_ERR(phy[i]);
+		if (IS_ERR(phy[i])) {
+			ret = PTR_ERR(phy[i]);
+			goto err_link;
+		}
 
 		link[i] = device_link_add(dev, &phy[i]->dev, DL_FLAG_STATELESS);
 		if (!link[i]) {
Signature · 1 line
2.46.0
#1 lore raw
Quoted 7 lines · Riyan Dhiman

While creation of device link, if devm_phy_get() function fails then it directly returns PTR_ERR without any cleanup of previous added device links. Added goto statement when devm_phy_get() fails, to handle the cleanup of already added device links.

Fixes 7a4db656a635 (PCI: dra7xx: Create functional dependency between PCIe and PHY)

Thanks for this. We're in the v6.12 merge window right now, so please post this again after v6.12-rc1 (probably Sep 29).

In subject and commit log, s/Added/Add/.

See https://chris.beams.io/posts/git-commit/ and
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/maintainer-tip.rst?id=v6.11#n134

Wrap commit log to fit in 75 columns.

Add blank line between paragraphs.

Quoted 24 lines
---
 drivers/pci/controller/dwc/pci-dra7xx.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/pci/controller/dwc/pci-dra7xx.c +4 -2
index 4fe3b0cb72ec..c329d107b811 100644
@@ -762,8 +762,10 @@ static int dra7xx_pcie_probe(struct platform_device *pdev)
 	for (i = 0; i < phy_count; i++) {
 		snprintf(name, sizeof(name), "pcie-phy%d", i);
 		phy[i] = devm_phy_get(dev, name);
-		if (IS_ERR(phy[i]))
-			return PTR_ERR(phy[i]);
+		if (IS_ERR(phy[i])) {
+			ret = PTR_ERR(phy[i]);
+			goto err_link;
+		}
 
 		link[i] = device_link_add(dev, &phy[i]->dev, DL_FLAG_STATELESS);
 		if (!link[i]) {
Signature · 1 line
2.46.0