Skip to content

Commit

Permalink
PCI: mediatek-gen3: Fix refcount leak in mtk_pcie_init_irq_domains()
Browse files Browse the repository at this point in the history
[ Upstream commit bf03850 ]

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: 814ccee ("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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Yuuoniy authored and gregkh committed Aug 17, 2022
1 parent c99dca4 commit 0675fe2
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion drivers/pci/controller/pcie-mediatek-gen3.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -623,13 +624,16 @@ 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:
irq_domain_remove(port->msi_bottom_domain);
err_msi_bottom_domain:
irq_domain_remove(port->intx_domain);

out_put_node:
of_node_put(intc_node);
return ret;
}

Expand Down

0 comments on commit 0675fe2

Please sign in to comment.