* [PATCH] PCI: xilinx: Fix INTx IRQ domain leak when MSI allocation fails
@ 2025-11-19 3:33 Haotian Zhang
2025-12-18 8:11 ` Manivannan Sadhasivam
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Haotian Zhang @ 2025-11-19 3:33 UTC (permalink / raw)
To: lpieralisi, kwilczynski, mani
Cc: robh, bhelgaas, michal.simek, linux-pci, linux-arm-kernel,
linux-kernel, Haotian Zhang
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.
Add irq_domain_remove() call in the error path to properly release the
IRQ domain before returning the error.
Fixes: 699ca3016268 ("PCI: xilinx: Check for __get_free_pages() failure")
Signed-off-by: Haotian Zhang <vulab@iscas.ac.cn>
---
drivers/pci/controller/pcie-xilinx.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/pci/controller/pcie-xilinx.c b/drivers/pci/controller/pcie-xilinx.c
index 937ea6ae1ac4..e8cf320f3764 100644
--- a/drivers/pci/controller/pcie-xilinx.c
+++ b/drivers/pci/controller/pcie-xilinx.c
@@ -480,8 +480,10 @@ static int xilinx_pcie_init_irq_domain(struct xilinx_pcie *pcie)
phys_addr_t pa = ALIGN_DOWN(virt_to_phys(pcie), SZ_4K);
ret = xilinx_allocate_msi_domains(pcie);
- if (ret)
+ if (ret) {
+ irq_domain_remove(pcie->leg_domain);
return ret;
+ }
pcie_write(pcie, upper_32_bits(pa), XILINX_PCIE_REG_MSIBASE1);
pcie_write(pcie, lower_32_bits(pa), XILINX_PCIE_REG_MSIBASE2);
--
2.50.1.windows.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] PCI: xilinx: Fix INTx IRQ domain leak when MSI allocation fails
2025-11-19 3:33 [PATCH] PCI: xilinx: Fix INTx IRQ domain leak when MSI allocation fails Haotian Zhang
@ 2025-12-18 8:11 ` Manivannan Sadhasivam
2025-12-18 10:23 ` [PATCH v2] " Haotian Zhang
2025-12-19 2:16 ` [PATCH v3] PCI: xilinx: Fix INTx IRQ domain leak in error paths Haotian Zhang
2 siblings, 0 replies; 6+ messages in thread
From: Manivannan Sadhasivam @ 2025-12-18 8:11 UTC (permalink / raw)
To: Haotian Zhang
Cc: lpieralisi, kwilczynski, robh, bhelgaas, michal.simek, linux-pci,
linux-arm-kernel, linux-kernel
On Wed, Nov 19, 2025 at 11:33:01AM +0800, Haotian Zhang wrote:
> 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.
>
> Add irq_domain_remove() call in the error path to properly release the
> IRQ domain before returning the error.
>
> Fixes: 699ca3016268 ("PCI: xilinx: Check for __get_free_pages() failure")
Is this the correct tag?
- Mani
> Signed-off-by: Haotian Zhang <vulab@iscas.ac.cn>
> ---
> drivers/pci/controller/pcie-xilinx.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/pci/controller/pcie-xilinx.c b/drivers/pci/controller/pcie-xilinx.c
> index 937ea6ae1ac4..e8cf320f3764 100644
> --- a/drivers/pci/controller/pcie-xilinx.c
> +++ b/drivers/pci/controller/pcie-xilinx.c
> @@ -480,8 +480,10 @@ static int xilinx_pcie_init_irq_domain(struct xilinx_pcie *pcie)
> phys_addr_t pa = ALIGN_DOWN(virt_to_phys(pcie), SZ_4K);
>
> ret = xilinx_allocate_msi_domains(pcie);
> - if (ret)
> + if (ret) {
> + irq_domain_remove(pcie->leg_domain);
> return ret;
> + }
>
> pcie_write(pcie, upper_32_bits(pa), XILINX_PCIE_REG_MSIBASE1);
> pcie_write(pcie, lower_32_bits(pa), XILINX_PCIE_REG_MSIBASE2);
> --
> 2.50.1.windows.1
>
--
மணிவண்ணன் சதாசிவம்
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2] PCI: xilinx: Fix INTx IRQ domain leak when MSI allocation fails
2025-11-19 3:33 [PATCH] PCI: xilinx: Fix INTx IRQ domain leak when MSI allocation fails Haotian Zhang
2025-12-18 8:11 ` Manivannan Sadhasivam
@ 2025-12-18 10:23 ` Haotian Zhang
2025-12-18 13:14 ` Manivannan Sadhasivam
2025-12-19 2:16 ` [PATCH v3] PCI: xilinx: Fix INTx IRQ domain leak in error paths Haotian Zhang
2 siblings, 1 reply; 6+ messages in thread
From: Haotian Zhang @ 2025-12-18 10:23 UTC (permalink / raw)
To: lpieralisi, kwilczynski, mani
Cc: robh, bhelgaas, michal.simek, linux-pci, linux-arm-kernel,
linux-kernel, Haotian Zhang
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.
Add irq_domain_remove() call in the error path to properly release the
IRQ domain before returning the error.
Fixes: 313b64c3ae52 ("PCI: xilinx: Convert to MSI domains")
Suggested-by: Manivannan Sadhasivam <mani@kernel.org>
Signed-off-by: Haotian Zhang <vulab@iscas.ac.cn>
---
Changes in v2:
- Correct the Fixes tag to point to the commit that introduced the
legacy IRQ domain leak on MSI allocation failure.
---
drivers/pci/controller/pcie-xilinx.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/pci/controller/pcie-xilinx.c b/drivers/pci/controller/pcie-xilinx.c
index 937ea6ae1ac4..e8cf320f3764 100644
--- a/drivers/pci/controller/pcie-xilinx.c
+++ b/drivers/pci/controller/pcie-xilinx.c
@@ -480,8 +480,10 @@ static int xilinx_pcie_init_irq_domain(struct xilinx_pcie *pcie)
phys_addr_t pa = ALIGN_DOWN(virt_to_phys(pcie), SZ_4K);
ret = xilinx_allocate_msi_domains(pcie);
- if (ret)
+ if (ret) {
+ irq_domain_remove(pcie->leg_domain);
return ret;
+ }
pcie_write(pcie, upper_32_bits(pa), XILINX_PCIE_REG_MSIBASE1);
pcie_write(pcie, lower_32_bits(pa), XILINX_PCIE_REG_MSIBASE2);
--
2.50.1.windows.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2] PCI: xilinx: Fix INTx IRQ domain leak when MSI allocation fails
2025-12-18 10:23 ` [PATCH v2] " Haotian Zhang
@ 2025-12-18 13:14 ` Manivannan Sadhasivam
0 siblings, 0 replies; 6+ messages in thread
From: Manivannan Sadhasivam @ 2025-12-18 13:14 UTC (permalink / raw)
To: Haotian Zhang
Cc: lpieralisi, kwilczynski, robh, bhelgaas, michal.simek, linux-pci,
linux-arm-kernel, linux-kernel
On Thu, Dec 18, 2025 at 06:23:14PM +0800, Haotian Zhang wrote:
> 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.
>
> Add irq_domain_remove() call in the error path to properly release the
> IRQ domain before returning the error.
>
> Fixes: 313b64c3ae52 ("PCI: xilinx: Convert to MSI domains")
> Suggested-by: Manivannan Sadhasivam <mani@kernel.org>
Sorry, I didn't suggest this change ;)
> Signed-off-by: Haotian Zhang <vulab@iscas.ac.cn>
> ---
> Changes in v2:
> - Correct the Fixes tag to point to the commit that introduced the
> legacy IRQ domain leak on MSI allocation failure.
> ---
> drivers/pci/controller/pcie-xilinx.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/pci/controller/pcie-xilinx.c b/drivers/pci/controller/pcie-xilinx.c
> index 937ea6ae1ac4..e8cf320f3764 100644
> --- a/drivers/pci/controller/pcie-xilinx.c
> +++ b/drivers/pci/controller/pcie-xilinx.c
> @@ -480,8 +480,10 @@ static int xilinx_pcie_init_irq_domain(struct xilinx_pcie *pcie)
> phys_addr_t pa = ALIGN_DOWN(virt_to_phys(pcie), SZ_4K);
>
> ret = xilinx_allocate_msi_domains(pcie);
> - if (ret)
> + if (ret) {
> + irq_domain_remove(pcie->leg_domain);
> return ret;
> + }
Looks like this domain is not removed in the further failure path. You need to
rename xilinx_free_msi_domains() to xilinx_free_irq_domains() and remove this
domain in that function as well.
- Mani
--
மணிவண்ணன் சதாசிவம்
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v3] PCI: xilinx: Fix INTx IRQ domain leak in error paths
2025-11-19 3:33 [PATCH] PCI: xilinx: Fix INTx IRQ domain leak when MSI allocation fails Haotian Zhang
2025-12-18 8:11 ` Manivannan Sadhasivam
2025-12-18 10:23 ` [PATCH v2] " Haotian Zhang
@ 2025-12-19 2:16 ` Haotian Zhang
2025-12-23 12:29 ` Manivannan Sadhasivam
2 siblings, 1 reply; 6+ messages in thread
From: Haotian Zhang @ 2025-12-19 2:16 UTC (permalink / raw)
To: lpieralisi, kwilczynski, mani
Cc: robh, bhelgaas, michal.simek, linux-pci, linux-arm-kernel,
linux-kernel, Haotian Zhang
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. Rename xilinx_free_msi_domains()
to xilinx_free_irq_domains() and add the release of pcie->leg_domain
in the function.
Fixes: 313b64c3ae52 ("PCI: xilinx: Convert to MSI domains")
Suggested-by: Manivannan Sadhasivam <mani@kernel.org>
Signed-off-by: Haotian Zhang <vulab@iscas.ac.cn>
---
Changes in v3:
- Rename xilinx_free_msi_domains() to xilinx_free_irq_domains()
and add the release of pcie->leg_domain in the function as
suggested by Manivannan Sadhasivam.
---
Changes in v2:
- Correct the Fixes tag to point to the commit that introduced the
legacy IRQ domain leak on MSI allocation failure.
---
drivers/pci/controller/pcie-xilinx.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/drivers/pci/controller/pcie-xilinx.c b/drivers/pci/controller/pcie-xilinx.c
index 937ea6ae1ac4..4aa139abac16 100644
--- a/drivers/pci/controller/pcie-xilinx.c
+++ b/drivers/pci/controller/pcie-xilinx.c
@@ -302,9 +302,10 @@ static int xilinx_allocate_msi_domains(struct xilinx_pcie *pcie)
return 0;
}
-static void xilinx_free_msi_domains(struct xilinx_pcie *pcie)
+static void xilinx_free_irq_domains(struct xilinx_pcie *pcie)
{
irq_domain_remove(pcie->msi_domain);
+ irq_domain_remove(pcie->leg_domain);
}
/* INTx Functions */
@@ -480,8 +481,10 @@ static int xilinx_pcie_init_irq_domain(struct xilinx_pcie *pcie)
phys_addr_t pa = ALIGN_DOWN(virt_to_phys(pcie), SZ_4K);
ret = xilinx_allocate_msi_domains(pcie);
- if (ret)
+ if (ret) {
+ irq_domain_remove(pcie->leg_domain);
return ret;
+ }
pcie_write(pcie, upper_32_bits(pa), XILINX_PCIE_REG_MSIBASE1);
pcie_write(pcie, lower_32_bits(pa), XILINX_PCIE_REG_MSIBASE2);
@@ -600,7 +603,7 @@ static int xilinx_pcie_probe(struct platform_device *pdev)
err = pci_host_probe(bridge);
if (err)
- xilinx_free_msi_domains(pcie);
+ xilinx_free_irq_domains(pcie);
return err;
}
--
2.50.1.windows.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v3] PCI: xilinx: Fix INTx IRQ domain leak in error paths
2025-12-19 2:16 ` [PATCH v3] PCI: xilinx: Fix INTx IRQ domain leak in error paths Haotian Zhang
@ 2025-12-23 12:29 ` Manivannan Sadhasivam
0 siblings, 0 replies; 6+ messages in thread
From: Manivannan Sadhasivam @ 2025-12-23 12:29 UTC (permalink / raw)
To: lpieralisi, kwilczynski, Haotian Zhang
Cc: robh, bhelgaas, michal.simek, linux-pci, linux-arm-kernel,
linux-kernel
On Fri, 19 Dec 2025 10:16:15 +0800, Haotian Zhang wrote:
> 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. Rename xilinx_free_msi_domains()
> to xilinx_free_irq_domains() and add the release of pcie->leg_domain
> in the function.
>
> [...]
Applied, thanks!
[1/1] PCI: xilinx: Fix INTx IRQ domain leak in error paths
commit: f42b3c053b1554d66af6fe45bb1ef357464c0456
Best regards,
--
Manivannan Sadhasivam <mani@kernel.org>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-12-23 12:29 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-19 3:33 [PATCH] PCI: xilinx: Fix INTx IRQ domain leak when MSI allocation fails Haotian Zhang
2025-12-18 8:11 ` Manivannan Sadhasivam
2025-12-18 10:23 ` [PATCH v2] " Haotian Zhang
2025-12-18 13:14 ` Manivannan Sadhasivam
2025-12-19 2:16 ` [PATCH v3] PCI: xilinx: Fix INTx IRQ domain leak in error paths Haotian Zhang
2025-12-23 12:29 ` Manivannan Sadhasivam
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox