]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
PCI: mediatek: Fix IRQ domain leak when MSI allocation fails
authorHaotian Zhang <vulab@iscas.ac.cn>
Wed, 19 Nov 2025 02:33:08 +0000 (10:33 +0800)
committerManivannan Sadhasivam <mani@kernel.org>
Thu, 18 Dec 2025 08:06:56 +0000 (13:36 +0530)
In mtk_pcie_init_irq_domain(), if mtk_pcie_allocate_msi_domains()
fails after port->irq_domain has been successfully created via
irq_domain_create_linear(), the function returns directly without
cleaning up the allocated IRQ domain, resulting in a resource leak.

Add irq_domain_remove() call in the error path to properly release the
INTx IRQ domain before returning the error.

Fixes: 43e6409db64d ("PCI: mediatek: Add MSI support for MT2712 and MT7622")
Signed-off-by: Haotian Zhang <vulab@iscas.ac.cn>
Signed-off-by: Manivannan Sadhasivam <mani@kernel.org>
Link: https://patch.msgid.link/20251119023308.476-1-vulab@iscas.ac.cn
drivers/pci/controller/pcie-mediatek.c

index 4b78b6528f9fd33138f021e816a0beb03e4dc558..5defa5cc4c2bdc870084134ec9f2590da88460a0 100644 (file)
@@ -585,8 +585,10 @@ static int mtk_pcie_init_irq_domain(struct mtk_pcie_port *port,
 
        if (IS_ENABLED(CONFIG_PCI_MSI)) {
                ret = mtk_pcie_allocate_msi_domains(port);
-               if (ret)
+               if (ret) {
+                       irq_domain_remove(port->irq_domain);
                        return ret;
+               }
        }
 
        return 0;