Skip to contentSkip to conversation

PCI: brcmstb: Fix for missing of_node_put

PATCH Applied Stanimir Varbanov 4 participants 4 messages Jan 22, 2025 – Feb 20, 2025

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

PATCH v2 1/1 PCI: brcmstb: Fix for missing of_node_put

A call to of_parse_phandle() is incrementing the refcount, of_node_put must be called when done the work on it. Add missing of_node_put() after the check for msi_np == np and MSI initialization.

Cc [email protected] # v5.10+
Fixes 40ca1bf580ef ("PCI: brcmstb: Add MSI support")

---
v1 -> v2:
- Use of_node_put instead of cleanups (Florian).
- Sent the patch separately from PCIe 2712 series (Florian).

 drivers/pci/controller/pcie-brcmstb.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
drivers/pci/controller/pcie-brcmstb.c +9 -4
index 744fe1a4cf9c..d171ee61eab3 100644
@@ -1844,7 +1844,7 @@ static struct pci_ops brcm7425_pcie_ops = {
 
 static int brcm_pcie_probe(struct platform_device *pdev)
 {
-	struct device_node *np = pdev->dev.of_node, *msi_np;
+	struct device_node *np = pdev->dev.of_node;
 	struct pci_host_bridge *bridge;
 	const struct pcie_cfg_data *data;
 	struct brcm_pcie *pcie;
@@ -1944,9 +1944,14 @@ static int brcm_pcie_probe(struct platform_device *pdev)
 		goto fail;
 	}
 
-	msi_np = of_parse_phandle(pcie->np, "msi-parent", 0);
-	if (pci_msi_enabled() && msi_np == pcie->np) {
-		ret = brcm_pcie_enable_msi(pcie);
+	if (pci_msi_enabled()) {
+		struct device_node *msi_np = of_parse_phandle(pcie->np, "msi-parent", 0);
+
+		if (msi_np == pcie->np)
+			ret = brcm_pcie_enable_msi(pcie);
+
+		of_node_put(msi_np);
+
 		if (ret) {
 			dev_err(pcie->dev, "probe of internal MSI failed");
 			goto fail;
Signature · 1 line
2.47.0
Reviewed-by on v2 1/1
#1 lore raw
Quoted 7 lines · Stanimir Varbanov

A call to of_parse_phandle() is incrementing the refcount, of_node_put must be called when done the work on it. Add missing of_node_put() after the check for msi_np == np and MSI initialization.

Cc [email protected] # v5.10+
Fixes 40ca1bf580ef ("PCI: brcmstb: Add MSI support")

- Mani

Quoted 42 lines

---
v1 -> v2:
- Use of_node_put instead of cleanups (Florian).
- Sent the patch separately from PCIe 2712 series (Florian).

 drivers/pci/controller/pcie-brcmstb.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
drivers/pci/controller/pcie-brcmstb.c +9 -4
index 744fe1a4cf9c..d171ee61eab3 100644
@@ -1844,7 +1844,7 @@ static struct pci_ops brcm7425_pcie_ops = {
 
 static int brcm_pcie_probe(struct platform_device *pdev)
 {
-	struct device_node *np = pdev->dev.of_node, *msi_np;
+	struct device_node *np = pdev->dev.of_node;
 	struct pci_host_bridge *bridge;
 	const struct pcie_cfg_data *data;
 	struct brcm_pcie *pcie;
@@ -1944,9 +1944,14 @@ static int brcm_pcie_probe(struct platform_device *pdev)
 		goto fail;
 	}
 
-	msi_np = of_parse_phandle(pcie->np, "msi-parent", 0);
-	if (pci_msi_enabled() && msi_np == pcie->np) {
-		ret = brcm_pcie_enable_msi(pcie);
+	if (pci_msi_enabled()) {
+		struct device_node *msi_np = of_parse_phandle(pcie->np, "msi-parent", 0);
+
+		if (msi_np == pcie->np)
+			ret = brcm_pcie_enable_msi(pcie);
+
+		of_node_put(msi_np);
+
 		if (ret) {
 			dev_err(pcie->dev, "probe of internal MSI failed");
 			goto fail;
Signature · 1 line
2.47.0
Signature · 1 line
மணிவண்ணன் சதாசிவம்
maintainer Reviewed-by on v2 1/1
#2 lore raw
In reply to Stanimir Varbanov
Quoted 7 lines · Stanimir Varbanov

A call to of_parse_phandle() is incrementing the refcount, of_node_put must be called when done the work on it. Add missing of_node_put() after the check for msi_np == np and MSI initialization.

Cc [email protected] # v5.10+
Fixes 40ca1bf580ef ("PCI: brcmstb: Add MSI support")
Signature · 1 line
Florian
#3 lore raw
In reply to Stanimir Varbanov

Hello,

Quoted 3 lines

A call to of_parse_phandle() is incrementing the refcount, of_node_put must be called when done the work on it. Add missing of_node_put() after the check for msi_np == np and MSI initialization.

Applied to controller/brcmstb, thank you!

Krzysztof