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

[ Upstream commit fc6c7cd387 ]

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: a5b659bd4b ("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
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
Lokesh Vutla
2020-11-02 17:36:31 +05:30
committed by Greg Kroah-Hartman
parent 629d6ba81f
commit 1ce041fad2

View File

@@ -129,7 +129,7 @@ static void ti_sci_intr_irq_domain_free(struct irq_domain *domain,
* @virq: Corresponding Linux virtual IRQ number * @virq: Corresponding Linux virtual IRQ number
* @hwirq: Corresponding hwirq for the IRQ within this IRQ domain * @hwirq: Corresponding hwirq for the IRQ within this IRQ domain
* *
* Returns parent irq if all went well else appropriate error pointer. * Returns intr output irq if all went well else appropriate error pointer.
*/ */
static int ti_sci_intr_alloc_parent_irq(struct irq_domain *domain, static int ti_sci_intr_alloc_parent_irq(struct irq_domain *domain,
unsigned int virq, u32 hwirq) unsigned int virq, u32 hwirq)
@@ -173,7 +173,7 @@ static int ti_sci_intr_alloc_parent_irq(struct irq_domain *domain,
if (err) if (err)
goto err_msg; goto err_msg;
return p_hwirq; return out_irq;
err_msg: err_msg:
irq_domain_free_irqs_parent(domain, virq, 1); irq_domain_free_irqs_parent(domain, virq, 1);
@@ -198,19 +198,19 @@ static int ti_sci_intr_irq_domain_alloc(struct irq_domain *domain,
struct irq_fwspec *fwspec = data; struct irq_fwspec *fwspec = data;
unsigned long hwirq; unsigned long hwirq;
unsigned int flags; unsigned int flags;
int err, p_hwirq; int err, out_irq;
err = ti_sci_intr_irq_domain_translate(domain, fwspec, &hwirq, &flags); err = ti_sci_intr_irq_domain_translate(domain, fwspec, &hwirq, &flags);
if (err) if (err)
return err; return err;
p_hwirq = ti_sci_intr_alloc_parent_irq(domain, virq, hwirq); out_irq = ti_sci_intr_alloc_parent_irq(domain, virq, hwirq);
if (p_hwirq < 0) if (out_irq < 0)
return p_hwirq; return out_irq;
irq_domain_set_hwirq_and_chip(domain, virq, hwirq, irq_domain_set_hwirq_and_chip(domain, virq, hwirq,
&ti_sci_intr_irq_chip, &ti_sci_intr_irq_chip,
(void *)(uintptr_t)p_hwirq); (void *)(uintptr_t)out_irq);
return 0; return 0;
} }