PCI: microchip: Fix refcount leak in mc_pcie_init_irq_domains()
authorMiaoqian Lin <linmq006@gmail.com>
Sun, 5 Jun 2022 05:51:23 +0000 (09:51 +0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 17 Aug 2022 12:23:40 +0000 (14:23 +0200)
[ Upstream commit f030304fdeb87ec8f1b518c73703214aec6cc24a ]

of_get_next_child() returns a node pointer with refcount incremented, so we
should use of_node_put() on it when we don't need it anymore.

mc_pcie_init_irq_domains() only calls of_node_put() in the normal path,
missing it in some error paths.  Add missing of_node_put() to avoid
refcount leak.

Fixes: 6f15a9c9f941 ("PCI: microchip: Add Microchip PolarFire PCIe controller driver")
Link: https://lore.kernel.org/r/20220605055123.59127-1-linmq006@gmail.com
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/pci/controller/pcie-microchip-host.c

index fa209ad067bf8c4515afee3838b1852a86f0b6c7..6e8a6540b377ba0d987563f0ba0fc81febf573d3 100644 (file)
@@ -894,6 +894,7 @@ static int mc_pcie_init_irq_domains(struct mc_port *port)
                                                   &event_domain_ops, port);
        if (!port->event_domain) {
                dev_err(dev, "failed to get event domain\n");
+               of_node_put(pcie_intc_node);
                return -ENOMEM;
        }
 
@@ -903,6 +904,7 @@ static int mc_pcie_init_irq_domains(struct mc_port *port)
                                                  &intx_domain_ops, port);
        if (!port->intx_domain) {
                dev_err(dev, "failed to get an INTx IRQ domain\n");
+               of_node_put(pcie_intc_node);
                return -ENOMEM;
        }