Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

irqchip/ti-sci-intr: Fix freeing of irqs

ti_sci_intr_irq_domain_free() assumes that out_irq of intr is stored in
data->chip_data and uses it for calling ti_sci irq_free() and then
mark the out_irq as available resource. But ti_sci_intr_irq_domain_alloc()
is storing p_hwirq(parent's hardware irq) which is translated from out_irq.
This is causing resource leakage and eventually out_irq resources might
be exhausted. Fix ti_sci_intr_irq_domain_alloc() by storing the out_irq
in data->chip_data.

Fixes: a5b659bd4bc7 ("irqchip/ti-sci-intr: Add support for INTR being a parent to INTR")
Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20201102120631.11165-1-lokeshvutla@ti.com

authored by

Lokesh Vutla and committed by
Marc Zyngier
fc6c7cd3 b10d5fd4

+7 -7
+7 -7
drivers/irqchip/irq-ti-sci-intr.c
··· 129 129 * @virq: Corresponding Linux virtual IRQ number 130 130 * @hwirq: Corresponding hwirq for the IRQ within this IRQ domain 131 131 * 132 - * Returns parent irq if all went well else appropriate error pointer. 132 + * Returns intr output irq if all went well else appropriate error pointer. 133 133 */ 134 134 static int ti_sci_intr_alloc_parent_irq(struct irq_domain *domain, 135 135 unsigned int virq, u32 hwirq) ··· 173 173 if (err) 174 174 goto err_msg; 175 175 176 - return p_hwirq; 176 + return out_irq; 177 177 178 178 err_msg: 179 179 irq_domain_free_irqs_parent(domain, virq, 1); ··· 198 198 struct irq_fwspec *fwspec = data; 199 199 unsigned long hwirq; 200 200 unsigned int flags; 201 - int err, p_hwirq; 201 + int err, out_irq; 202 202 203 203 err = ti_sci_intr_irq_domain_translate(domain, fwspec, &hwirq, &flags); 204 204 if (err) 205 205 return err; 206 206 207 - p_hwirq = ti_sci_intr_alloc_parent_irq(domain, virq, hwirq); 208 - if (p_hwirq < 0) 209 - return p_hwirq; 207 + out_irq = ti_sci_intr_alloc_parent_irq(domain, virq, hwirq); 208 + if (out_irq < 0) 209 + return out_irq; 210 210 211 211 irq_domain_set_hwirq_and_chip(domain, virq, hwirq, 212 212 &ti_sci_intr_irq_chip, 213 - (void *)(uintptr_t)p_hwirq); 213 + (void *)(uintptr_t)out_irq); 214 214 215 215 return 0; 216 216 }