Skip to content

Commit c26591a

Browse files
Guanrui HuangKAGA-KOKO
authored andcommitted
irqchip/gic-v3-its: Prevent double free on error
The error handling path in its_vpe_irq_domain_alloc() causes a double free when its_vpe_init() fails after successfully allocating at least one interrupt. This happens because its_vpe_irq_domain_free() frees the interrupts along with the area bitmap and the vprop_page and its_vpe_irq_domain_alloc() subsequently frees the area bitmap and the vprop_page again. Fix this by unconditionally invoking its_vpe_irq_domain_free() which handles all cases correctly and by removing the bitmap/vprop_page freeing from its_vpe_irq_domain_alloc(). [ tglx: Massaged change log ] Fixes: 7d75bbb ("irqchip/gic-v3-its: Add VPE irq domain allocation/teardown") Signed-off-by: Guanrui Huang <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Reviewed-by: Marc Zyngier <[email protected]> Reviewed-by: Zenghui Yu <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/r/[email protected]
1 parent ed30a4a commit c26591a

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

drivers/irqchip/irq-gic-v3-its.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4567,13 +4567,8 @@ static int its_vpe_irq_domain_alloc(struct irq_domain *domain, unsigned int virq
45674567
irqd_set_resend_when_in_progress(irq_get_irq_data(virq + i));
45684568
}
45694569

4570-
if (err) {
4571-
if (i > 0)
4572-
its_vpe_irq_domain_free(domain, virq, i);
4573-
4574-
its_lpi_free(bitmap, base, nr_ids);
4575-
its_free_prop_table(vprop_page);
4576-
}
4570+
if (err)
4571+
its_vpe_irq_domain_free(domain, virq, i);
45774572

45784573
return err;
45794574
}

0 commit comments

Comments
 (0)