linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] PCI: dra7xx: Fix link removal on probe error
@ 2021-12-14 22:14 Luca Ceresoli
  2021-12-14 22:14 ` [PATCH 2/2] PCI: dra7xx: Fix clk disabling in some error paths Luca Ceresoli
  2021-12-14 22:42 ` [PATCH 1/2] PCI: dra7xx: Fix link removal on probe error Rob Herring
  0 siblings, 2 replies; 12+ messages in thread
From: Luca Ceresoli @ 2021-12-14 22:14 UTC (permalink / raw)
  To: linux-pci
  Cc: Luca Ceresoli, Dan Carpenter, linux-omap, linux-arm-kernel,
	linux-kernel, Kishon Vijay Abraham I, Lorenzo Pieralisi,
	Rob Herring, Krzysztof Wilczyński, Bjorn Helgaas,
	Sekhar Nori

If a devm_phy_get() calls fails with phy_count==N (N > 0), then N links
have already been added by device_link_add() and won't be deleted by
device_link_del() because the code calls 'return' and not 'goto err_link'.

Fix in a very simple way by doing all the devm_phy_get() calls before all
the device_link_add() calls.

Fixes: 7a4db656a635 ("PCI: dra7xx: Create functional dependency between PCIe and PHY")
Signed-off-by: Luca Ceresoli <luca@lucaceresoli.net>
---
 drivers/pci/controller/dwc/pci-dra7xx.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/pci/controller/dwc/pci-dra7xx.c b/drivers/pci/controller/dwc/pci-dra7xx.c
index f7f1490e7beb..2ccc53869e13 100644
--- a/drivers/pci/controller/dwc/pci-dra7xx.c
+++ b/drivers/pci/controller/dwc/pci-dra7xx.c
@@ -757,7 +757,9 @@ static int dra7xx_pcie_probe(struct platform_device *pdev)
 		phy[i] = devm_phy_get(dev, name);
 		if (IS_ERR(phy[i]))
 			return PTR_ERR(phy[i]);
+	}
 
+	for (i = 0; i < phy_count; i++) {
 		link[i] = device_link_add(dev, &phy[i]->dev, DL_FLAG_STATELESS);
 		if (!link[i]) {
 			ret = -EINVAL;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2022-05-23 13:28 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-14 22:14 [PATCH 1/2] PCI: dra7xx: Fix link removal on probe error Luca Ceresoli
2021-12-14 22:14 ` [PATCH 2/2] PCI: dra7xx: Fix clk disabling in some error paths Luca Ceresoli
2021-12-14 22:42 ` [PATCH 1/2] PCI: dra7xx: Fix link removal on probe error Rob Herring
2021-12-16  9:08   ` Luca Ceresoli
2022-01-11 10:35     ` Luca Ceresoli
2022-01-15 16:02       ` Rob Herring
2022-05-11 16:41         ` Lorenzo Pieralisi
2022-05-12 14:07           ` Luca Ceresoli
2022-05-14  3:46             ` Saravana Kannan
2022-05-17  7:32               ` Luca Ceresoli
2022-05-19 20:25                 ` Saravana Kannan
2022-05-23 13:28                   ` Luca Ceresoli

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).