Skip to contentSkip to conversation

pci: controller: brcmstb: Move of_node_put() out of 'if' in brcm_pcie_probe

PATCH In review Liang He 2 participants 3 messages Jul 4, 2022 – Jul 15, 2022

Subsystems (5)
lore
Share & tools
lore

Liang He

author
#0 lore raw

PATCH 1/1 pci: controller: brcmstb: Move of_node_put() out of 'if' in brcm_pcie_probe

Commit 3a87cb8f6a ("Fix refcount leak in brcm_pcie_probe()") adds of_node_put() for of_parse_phandle() in fail path but not adds it correctly in normal path. We should move the second of_node_put() out of the 'if(pci_msi_enabled() && msi_np == pcie->np)'.

Fixes 3a87cb8f6a ("Fix refcount leak in brcm_pcie_probe()")

---
Patched file has been compiled test in next branch.

 drivers/pci/controller/pcie-brcmstb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/controller/pcie-brcmstb.c +1 -1
index 48a7148376d4..80e19d053e9f 100755
@@ -1413,8 +1413,8 @@ static int brcm_pcie_probe(struct platform_device *pdev)
 			of_node_put(msi_np);
 			goto fail;
 		}
-		of_node_put(msi_np);
 	}
+	of_node_put(msi_np);
 
 	bridge->ops = pcie->type == BCM7425 ? &brcm_pcie_ops32 : &brcm_pcie_ops;
 	bridge->sysdata = pcie;
Signature · 1 line
2.25.1
#1 lore raw
Quoted 19 lines · Liang He

Commit 3a87cb8f6a ("Fix refcount leak in brcm_pcie_probe()") adds of_node_put() for of_parse_phandle() in fail path but not adds it correctly in normal path. We should move the second of_node_put() out of the 'if(pci_msi_enabled() && msi_np == pcie->np)'.

Fixes 3a87cb8f6a ("Fix refcount leak in brcm_pcie_probe()")

---
Patched file has been compiled test in next branch.

 drivers/pci/controller/pcie-brcmstb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/controller/pcie-brcmstb.c +0 -0
index 48a7148376d4..80e19d053e9f 100755

drivers/pci/controller/pcie-brcmstb.c static int brcm_pcie_probe(struct platform_device *pdev) · line 1417

Quoted 6 lines
drivers/pci/controller/pcie-brcmstb.c +1 -1
@@ -1413,8 +1413,8 @@ static int brcm_pcie_probe(struct platform_device *pdev)
 			of_node_put(msi_np);
 			goto fail;
 		}
-		of_node_put(msi_np);
 	}
+	of_node_put(msi_np);

Can we just move the of_parse_phandle() and related checking into brcm_pcie_enable_msi()? It can return success without doing anything if !pci_msi_enabled() or msi_np != pcie_np.

If you don't want to do that, please just send a revised version of 3a87cb8f6a72 ("PCI: brcmstb: Fix refcount leak in brcm_pcie_probe()"). That's not upstream yet, and I don't want to clutter the git history with a fix of a fix.

Quoted 5 lines
drivers/pci/controller/pcie-brcmstb.c +0 -0
 	bridge->ops = pcie->type == BCM7425 ? &brcm_pcie_ops32 : &brcm_pcie_ops;
 	bridge->sysdata = pcie;
Signature · 1 line
2.25.1
author
#2 lore raw
Quoted 31 lines · Bjorn Helgaas
Quoted 19 lines · Liang He

Commit 3a87cb8f6a ("Fix refcount leak in brcm_pcie_probe()") adds of_node_put() for of_parse_phandle() in fail path but not adds it correctly in normal path. We should move the second of_node_put() out of the 'if(pci_msi_enabled() && msi_np == pcie->np)'.

Fixes 3a87cb8f6a ("Fix refcount leak in brcm_pcie_probe()")

---
Patched file has been compiled test in next branch.

 drivers/pci/controller/pcie-brcmstb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/controller/pcie-brcmstb.c +0 -0
index 48a7148376d4..80e19d053e9f 100755

drivers/pci/controller/pcie-brcmstb.c static int brcm_pcie_probe(struct platform_device *pdev) · line 1417

Quoted 6 lines
drivers/pci/controller/pcie-brcmstb.c +1 -1
@@ -1413,8 +1413,8 @@ static int brcm_pcie_probe(struct platform_device *pdev)
 			of_node_put(msi_np);
 			goto fail;
 		}
-		of_node_put(msi_np);
 	}
+	of_node_put(msi_np);

Can we just move the of_parse_phandle() and related checking into brcm_pcie_enable_msi()? It can return success without doing anything if !pci_msi_enabled() or msi_np != pcie_np.

Quoted 6 lines

If you don't want to do that, please just send a revised version of 3a87cb8f6a72 ("PCI: brcmstb: Fix refcount leak in brcm_pcie_probe()"). That's not upstream yet, and I don't want to clutter the git history with a fix of a fix.

Thanks, Bjorn,
We will make a better version or a revised version soon. Liang

Quoted 5 lines
Quoted 5 lines
drivers/pci/controller/pcie-brcmstb.c +0 -0
 	bridge->ops = pcie->type == BCM7425 ? &brcm_pcie_ops32 : &brcm_pcie_ops;
 	bridge->sysdata = pcie;
Signature · 1 line
2.25.1