[PATCH 5.15 412/779] PCI: mediatek-gen3: Fix refcount leak in mtk_pcie_init_irq_domains()
From: Greg Kroah-Hartman
Date: Mon Aug 15 2022 - 15:10:06 EST
From: Miaoqian Lin <linmq006@xxxxxxxxx>
[ Upstream commit bf038503d5fe90189743124233fe7aeb0984e961 ]
of_get_child_by_name() returns a node pointer with refcount incremented, so
we should use of_node_put() on it when we don't need it anymore.
Add missing of_node_put() to avoid refcount leak.
Fixes: 814cceebba9b ("PCI: mediatek-gen3: Add INTx support")
Link: https://lore.kernel.org/r/20220601041259.56185-1-linmq006@xxxxxxxxx
Signed-off-by: Miaoqian Lin <linmq006@xxxxxxxxx>
Signed-off-by: Bjorn Helgaas <bhelgaas@xxxxxxxxxx>
Reviewed-by: Miles Chen <miles.chen@xxxxxxxxxxxx>
Acked-by: Jianjun Wang <jianjun.wang@xxxxxxxxxxxx>
Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>
---
drivers/pci/controller/pcie-mediatek-gen3.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/pci/controller/pcie-mediatek-gen3.c b/drivers/pci/controller/pcie-mediatek-gen3.c
index 21207df680cc..36c8702439e9 100644
--- a/drivers/pci/controller/pcie-mediatek-gen3.c
+++ b/drivers/pci/controller/pcie-mediatek-gen3.c
@@ -600,7 +600,8 @@ static int mtk_pcie_init_irq_domains(struct mtk_pcie_port *port)
&intx_domain_ops, port);
if (!port->intx_domain) {
dev_err(dev, "failed to create INTx IRQ domain\n");
- return -ENODEV;
+ ret = -ENODEV;
+ goto out_put_node;
}
/* Setup MSI */
@@ -623,6 +624,7 @@ static int mtk_pcie_init_irq_domains(struct mtk_pcie_port *port)
goto err_msi_domain;
}
+ of_node_put(intc_node);
return 0;
err_msi_domain:
@@ -630,6 +632,8 @@ static int mtk_pcie_init_irq_domains(struct mtk_pcie_port *port)
err_msi_bottom_domain:
irq_domain_remove(port->intx_domain);
+out_put_node:
+ of_node_put(intc_node);
return ret;
}
--
2.35.1