Skip to contentSkip to conversation

irqchip/ingenic-tcu: free generic chips on error path

PATCH In review Haotian Zhang 2 participants 2 messages Aug 18 – Aug 19 irqchip drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 irqchip/ingenic-tcu: free generic chips on error path

irq_alloc_domain_generic_chips() stores the allocated generic chip data in domain->gc. On the error path taken when irq_of_parse_and_map() fails, ingenic_tcu_irq_init() calls irq_domain_remove() without first calling irq_domain_remove_generic_chips(). As the domain was created with irq_domain_add_linear(), which does not set IRQ_DOMAIN_FLAG_DESTROY_GC, irq_domain_remove() never frees the generic chips and the allocation leaks.

Call irq_domain_remove_generic_chips() before irq_domain_remove() so that the generic chip data is released on the error path.

Fixes 9536eba03ec7 ("irqchip: Add irq-ingenic-tcu driver")
---
 drivers/irqchip/irq-ingenic-tcu.c | 1 +
 1 file changed, 1 insertion(+)
drivers/irqchip/irq-ingenic-tcu.c +1 -0
index 794ecba717c9..637fd90d97aa 100644
@@ -171,6 +171,7 @@ static int __init ingenic_tcu_irq_init(struct device_node *np,
 	for (; i > 0; i--)
 		irq_dispose_mapping(tcu->parent_irqs[i - 1]);
 out_domain_remove:
+	irq_domain_remove_generic_chips(tcu->domain);
 	irq_domain_remove(tcu->domain);
 err_free_tcu:
 	kfree(tcu);
Signature · 1 line
2.43.0
#1 lore raw
Quoted 10 lines · Haotian Zhang

irq_alloc_domain_generic_chips() stores the allocated generic chip data in domain->gc. On the error path taken when irq_of_parse_and_map() fails, ingenic_tcu_irq_init() calls irq_domain_remove() without first calling irq_domain_remove_generic_chips(). As the domain was created with irq_domain_add_linear(), which does not set IRQ_DOMAIN_FLAG_DESTROY_GC, irq_domain_remove() never frees the generic chips and the allocation leaks.

Call irq_domain_remove_generic_chips() before irq_domain_remove() so that the generic chip data is released on the error path.

No. Set the stupid flag on the domain and let the core code do it.