[tip: irq/core] irqdomain: Plug leak in irq_domain_alloc_irqs_locked() error path

From: tip-bot2 for Kemeng Shi

Date: Mon Jun 29 2026 - 10:11:37 EST


The following commit has been merged into the irq/core branch of tip:

Commit-ID: 13856e22217fbf7c1200633716ff87ccb50fd89a
Gitweb: https://git.kernel.org/tip/13856e22217fbf7c1200633716ff87ccb50fd89a
Author: Kemeng Shi <shikemeng@xxxxxxxxxxxxxxx>
AuthorDate: Tue, 23 Jun 2026 15:51:32 +08:00
Committer: Thomas Gleixner <tglx@xxxxxxxxxx>
CommitterDate: Mon, 29 Jun 2026 15:42:26 +02:00

irqdomain: Plug leak in irq_domain_alloc_irqs_locked() error path

When irq_domain_trim_hierarchy() fails in irq_domain_alloc_irqs_locked(),
the error handling path fails to undo the hierarchy allocations.

Add the missing cleanup.

[ tglx: Massage change log ]

Signed-off-by: Kemeng Shi <shikemeng@xxxxxxxxxxxxxxx>
Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxx>
Link: https://patch.msgid.link/20260623075134.4432-2-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 f15c9f1..f76f516 100644
--- a/kernel/irq/irqdomain.c
+++ b/kernel/irq/irqdomain.c
@@ -1658,7 +1658,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++)
@@ -1666,6 +1666,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: