Skip to contentSkip to conversation

PCI: imx6: Add missing of_node_put() in imx6_pcie_probe

PATCH In review Miaoqian Lin 3 participants 3 messages Mar 8, 2022 – Mar 10, 2022

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

PATCH 1/1 PCI: imx6: Add missing of_node_put() in imx6_pcie_probe

The device_node pointer is returned by of_parse_phandle() with refcount incremented. We should use of_node_put() on it when done.

Fixes 1df82ec46600 ("PCI: imx: Add workaround for e10728, IMX7d PCIe PLL failure")
---
 drivers/pci/controller/dwc/pci-imx6.c | 1 +
 1 file changed, 1 insertion(+)
drivers/pci/controller/dwc/pci-imx6.c +1 -0
index 6974bd5aa116..bcc338ab6c11 100644
@@ -1050,6 +1050,7 @@ static int imx6_pcie_probe(struct platform_device *pdev)
 		struct resource res;
 
 		ret = of_address_to_resource(np, 0, &res);
+		of_node_put(np);
 		if (ret) {
 			dev_err(dev, "Unable to map PCIe PHY\n");
 			return ret;
Signature · 1 line
2.17.1
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 15 lines

-----Original Message-----
From: Miaoqian Lin <[email protected]>
Sent: 2022年3月8日 10:29
To: Hongxing Zhu <[email protected]>; Lucas Stach <[email protected]>; Lorenzo Pieralisi <[email protected]>; Rob Herring <[email protected]>; Krzysztof Wilczyński <[email protected]>; Bjorn Helgaas <[email protected]>; Shawn Guo <[email protected]>; Sascha Hauer <[email protected]>; Pengutronix Kernel Team <[email protected]>; Fabio Estevam <[email protected]>; dl-linux-imx <[email protected]>; Trent Piepho <[email protected]>; [email protected]; [email protected]; [email protected]
Cc: [email protected]
Subject: [PATCH] PCI: imx6: Add missing of_node_put() in imx6_pcie_probe

Quoted 6 lines

The device_node pointer is returned by of_parse_phandle() with refcount incremented. We should use of_node_put() on it when done.

Fixes 1df82ec46600 ("PCI: imx: Add workaround for e10728, IMX7d PCIe PLL

failure")

Thanks.

Best Regards
Richard Zhu

Quoted 20 lines
---
 drivers/pci/controller/dwc/pci-imx6.c | 1 +
 1 file changed, 1 insertion(+)
drivers/pci/controller/dwc/pci-imx6.c +1 -0
index 6974bd5aa116..bcc338ab6c11 100644
@@ -1050,6 +1050,7 @@ static int imx6_pcie_probe(struct platform_device
 *pdev)
 		struct resource res;
 
 		ret = of_address_to_resource(np, 0, &res);
+		of_node_put(np);
 		if (ret) {
 			dev_err(dev, "Unable to map PCIe PHY\n");

return ret;
--
2.17.1

reviewer
#2 lore raw
In reply to Miaoqian Lin
Quoted 15 lines · Miaoqian Lin

The device_node pointer is returned by of_parse_phandle() with refcount incremented. We should use of_node_put() on it when done.

Fixes 1df82ec46600 ("PCI: imx: Add workaround for e10728, IMX7d PCIe PLL failure")
---
 drivers/pci/controller/dwc/pci-imx6.c | 1 +
 1 file changed, 1 insertion(+)
drivers/pci/controller/dwc/pci-imx6.c +0 -0
index 6974bd5aa116..bcc338ab6c11 100644

drivers/pci/controller/dwc/pci-imx6.c static int imx6_pcie_probe(struct platform_device *pdev) · line 1053

Quoted 4 lines
drivers/pci/controller/dwc/pci-imx6.c +1 -0
@@ -1050,6 +1050,7 @@ static int imx6_pcie_probe(struct platform_device *pdev)
                struct resource res;
 
                ret = of_address_to_resource(np, 0, &res);
+               of_node_put(np);

So now you are using the phy within the driver, but not holding a reference to its node? That is wrong. Though if a struct device was created for the phy's node, it would hold a reference. There are a bunch of error paths where the reference should be dropped. But really, this driver is a big mess with the phy binding and framework not used and your nodes probably aren't going to be disappearing on you anyways.

Rob