]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
PCI: mediatek-gen3: Fix refcount leak in mtk_pcie_init_irq_domains()
authorMiaoqian Lin <linmq006@gmail.com>
Wed, 1 Jun 2022 04:12:58 +0000 (08:12 +0400)
committerBjorn Helgaas <bhelgaas@google.com>
Thu, 9 Jun 2022 17:23:59 +0000 (12:23 -0500)
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@gmail.com
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Miles Chen <miles.chen@mediatek.com>
Acked-by: Jianjun Wang <jianjun.wang@mediatek.com>
drivers/pci/controller/pcie-mediatek-gen3.c

index 5d9fd36b02d18122cc222d6e7eafff886b300fbf..a02c466a597cd2ffcf8c3ca1be8c463f41372387 100644 (file)
@@ -600,7 +600,8 @@ static int mtk_pcie_init_irq_domains(struct mtk_gen3_pcie *pcie)
                                                  &intx_domain_ops, pcie);
        if (!pcie->intx_domain) {
                dev_err(dev, "failed to create INTx IRQ domain\n");
-               return -ENODEV;
+               ret = -ENODEV;
+               goto out_put_node;
        }
 
        /* Setup MSI */
@@ -623,13 +624,15 @@ static int mtk_pcie_init_irq_domains(struct mtk_gen3_pcie *pcie)
                goto err_msi_domain;
        }
 
+       of_node_put(intc_node);
        return 0;
 
 err_msi_domain:
        irq_domain_remove(pcie->msi_bottom_domain);
 err_msi_bottom_domain:
        irq_domain_remove(pcie->intx_domain);
-
+out_put_node:
+       of_node_put(intc_node);
        return ret;
 }