Skip to content

Commit f42b3c0

Browse files
ISCAS-VulabMani-Sadhasivam
authored andcommitted
PCI: xilinx: Fix INTx IRQ domain leak in error paths
In xilinx_pcie_init_irq_domain(), if xilinx_allocate_msi_domains() fails after pcie->leg_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. In xilinx_free_msi_domains(), pcie->leg_domain is also neglected. Add irq_domain_remove() call in the error path to properly release the IRQ domain before returning the error. Also rename xilinx_free_msi_domains() to xilinx_free_irq_domains() and add the release of pcie->leg_domain to it. Fixes: 313b64c ("PCI: xilinx: Convert to MSI domains") Suggested-by: Manivannan Sadhasivam <mani@kernel.org> Signed-off-by: Haotian Zhang <vulab@iscas.ac.cn> Signed-off-by: Manivannan Sadhasivam <mani@kernel.org> Link: https://patch.msgid.link/20251219021615.965-1-vulab@iscas.ac.cn
1 parent 8f0b4cc commit f42b3c0

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

drivers/pci/controller/pcie-xilinx.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -302,9 +302,10 @@ static int xilinx_allocate_msi_domains(struct xilinx_pcie *pcie)
302302
return 0;
303303
}
304304

305-
static void xilinx_free_msi_domains(struct xilinx_pcie *pcie)
305+
static void xilinx_free_irq_domains(struct xilinx_pcie *pcie)
306306
{
307307
irq_domain_remove(pcie->msi_domain);
308+
irq_domain_remove(pcie->leg_domain);
308309
}
309310

310311
/* INTx Functions */
@@ -480,8 +481,10 @@ static int xilinx_pcie_init_irq_domain(struct xilinx_pcie *pcie)
480481
phys_addr_t pa = ALIGN_DOWN(virt_to_phys(pcie), SZ_4K);
481482

482483
ret = xilinx_allocate_msi_domains(pcie);
483-
if (ret)
484+
if (ret) {
485+
irq_domain_remove(pcie->leg_domain);
484486
return ret;
487+
}
485488

486489
pcie_write(pcie, upper_32_bits(pa), XILINX_PCIE_REG_MSIBASE1);
487490
pcie_write(pcie, lower_32_bits(pa), XILINX_PCIE_REG_MSIBASE2);
@@ -600,7 +603,7 @@ static int xilinx_pcie_probe(struct platform_device *pdev)
600603

601604
err = pci_host_probe(bridge);
602605
if (err)
603-
xilinx_free_msi_domains(pcie);
606+
xilinx_free_irq_domains(pcie);
604607

605608
return err;
606609
}

0 commit comments

Comments
 (0)