Skip to contentSkip to conversation

PCI: mediatek: Fix IRQ domain leak when MSI allocation fails

PATCH Applied Haotian Zhang 2 participants 2 messages Nov 19, 2025 – Dec 18, 2025

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 PCI: mediatek: Fix IRQ domain leak when MSI allocation fails

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")
---
 drivers/pci/controller/pcie-mediatek.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/pci/controller/pcie-mediatek.c +3 -1
index 24cc30a2ab6c..e0bf667c2b4c 100644
@@ -575,8 +575,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;
Signature · 1 line
2.50.1.windows.1
#1 lore raw
Quoted 9 lines · Haotian Zhang

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.

[...]

Applied, thanks!

[1/1] PCI: mediatek: Fix IRQ domain leak when MSI allocation fails

      commit: 7f0cdcddf8bef1c8c18f9be6708073fd3790a20f

Best regards,

Signature · 1 line
Manivannan Sadhasivam <[email protected]>