[PATCH 04/10] EDAC/altera: Fix IRQ domain leak on platform_get_irq() failure

Dinh Nguyen <[email protected]> Mon, 27 Jul 2026 08:24:10 -0500
Newsgroups org.kernel.vger.linux-edac,org.kernel.vger.linux-kernel,org.kernel.vger.stable
Message-ID <[email protected]>
sashiko reports: If platform_get_irq() fails, the function returns without
freeing the previously allocated edac->domain.

altr_edac_a10_probe() created an IRQ domain via irq_domain_create_linear()
but returned without freeing it when the subsequent platform_get_irq()
calls for the SB or DB IRQ failed, leaking the domain. Call
irq_domain_remove() before returning on those error paths.

Assisted-by: Cursor:claude-4.8-opus
Fixes: 13ab8448d2c9 ("EDAC, altera: Add ECC Manager IRQ controller support")
Cc: [email protected]
Signed-off-by: Dinh Nguyen <[email protected]>
---
 drivers/edac/altera_edac.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/edac/altera_edac.c b/drivers/edac/altera_edac.c
index 8cbf71ce5d2d8..e5d225f799f39 100644
--- a/drivers/edac/altera_edac.c
+++ b/drivers/edac/altera_edac.c
@@ -2179,8 +2179,10 @@ static int altr_edac_a10_probe(struct platform_device *pdev)
 	}
 
 	edac->sb_irq = platform_get_irq(pdev, 0);
-	if (edac->sb_irq < 0)
+	if (edac->sb_irq < 0) {
+		irq_domain_remove(edac->domain);
 		return edac->sb_irq;
+	}
 
 	irq_set_chained_handler_and_data(edac->sb_irq,
 					 altr_edac_a10_irq_handler,
@@ -2210,8 +2212,10 @@ static int altr_edac_a10_probe(struct platform_device *pdev)
 		}
 	} else {
 		edac->db_irq = platform_get_irq(pdev, 1);
-		if (edac->db_irq < 0)
+		if (edac->db_irq < 0) {
+			irq_domain_remove(edac->domain);
 			return edac->db_irq;
+		}
 
 		irq_set_chained_handler_and_data(edac->db_irq,
 						 altr_edac_a10_irq_handler, edac);
-- 
2.42.0.411.g813d9a9188