[PATCH 1/3] irqdomain: Fix leaks in irq_domain_alloc_irqs_locked()
From: Kemeng Shi
Date: Tue Jun 23 2026 - 03:52:41 EST
Free hierarchy irqs when irq_domain_trim_hierarchy() fails in
irq_domain_alloc_irqs_locked(). The irq_domain_trim_hierarchy() is unlikely
to fail, but there is no harm to add extra protection.
Signed-off-by: Kemeng Shi <shikemeng@xxxxxxxxxxxxxxx>
---
kernel/irq/irqdomain.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c
index cc93abf009e8..8bd86deacf0c 100644
--- a/kernel/irq/irqdomain.c
+++ b/kernel/irq/irqdomain.c
@@ -1655,7 +1655,7 @@ static int irq_domain_alloc_irqs_locked(struct irq_domain *domain, int irq_base,
for (i = 0; i < nr_irqs; i++) {
ret = irq_domain_trim_hierarchy(virq + i);
if (ret)
- goto out_free_irq_data;
+ goto out_free_irqs;
}
for (i = 0; i < nr_irqs; i++)
@@ -1663,6 +1663,8 @@ static int irq_domain_alloc_irqs_locked(struct irq_domain *domain, int irq_base,
return virq;
+out_free_irqs:
+ irq_domain_free_irqs_hierarchy(domain, virq, nr_irqs);
out_free_irq_data:
irq_domain_free_irq_data(virq, nr_irqs);
out_free_desc:
--
2.36.1