Skip to content

Commit ba8991a

Browse files
Stanimir Varbanovjfvogel
authored andcommitted
PCI: brcmstb: Fix missing of_node_put() in brcm_pcie_probe()
commit 2df181e1aea4628a8fd257f866026625d0519627 upstream. A call to of_parse_phandle() is incrementing the refcount, and as such, the of_node_put() must be called when the reference is no longer needed. Thus, refactor the existing code and add a missing of_node_put() call following the check to ensure that "msi_np" matches "pcie->np" and after MSI initialization, but only if the MSI support is enabled system-wide. Cc: [email protected] # v5.10+ Fixes: 40ca1bf ("PCI: brcmstb: Add MSI support") Signed-off-by: Stanimir Varbanov <[email protected]> Reviewed-by: Florian Fainelli <[email protected]> Reviewed-by: Manivannan Sadhasivam <[email protected]> Link: https://lore.kernel.org/r/[email protected] [kwilczynski: commit log] Signed-off-by: Krzysztof Wilczyński <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]> (cherry picked from commit 71bf0769a6c63b6f2e2774a5b7eef8af854a89f1) Signed-off-by: Jack Vogel <[email protected]>
1 parent 70ec177 commit ba8991a

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

drivers/pci/controller/pcie-brcmstb.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1786,7 +1786,7 @@ static struct pci_ops brcm7425_pcie_ops = {
17861786

17871787
static int brcm_pcie_probe(struct platform_device *pdev)
17881788
{
1789-
struct device_node *np = pdev->dev.of_node, *msi_np;
1789+
struct device_node *np = pdev->dev.of_node;
17901790
struct pci_host_bridge *bridge;
17911791
const struct pcie_cfg_data *data;
17921792
struct brcm_pcie *pcie;
@@ -1890,9 +1890,14 @@ static int brcm_pcie_probe(struct platform_device *pdev)
18901890
goto fail;
18911891
}
18921892

1893-
msi_np = of_parse_phandle(pcie->np, "msi-parent", 0);
1894-
if (pci_msi_enabled() && msi_np == pcie->np) {
1895-
ret = brcm_pcie_enable_msi(pcie);
1893+
if (pci_msi_enabled()) {
1894+
struct device_node *msi_np = of_parse_phandle(pcie->np, "msi-parent", 0);
1895+
1896+
if (msi_np == pcie->np)
1897+
ret = brcm_pcie_enable_msi(pcie);
1898+
1899+
of_node_put(msi_np);
1900+
18961901
if (ret) {
18971902
dev_err(pcie->dev, "probe of internal MSI failed");
18981903
goto fail;

0 commit comments

Comments
 (0)