[PATCH v5 08/14] irqchip/ls1x: Fix potential resource leaks

From: Tiezhu Yang
Date: Sun Jul 05 2020 - 21:19:53 EST


In the function ls1x_intc_of_init(), system resource "parent_irq"
was not released in two error cases. Thus add a jump target for
the completion of the desired exception handling.

Fixes: 9e543e22e204 ("irqchip: Add driver for Loongson-1 interrupt controller")
Signed-off-by: Tiezhu Yang <yangtiezhu@xxxxxxxxxxx>
---
drivers/irqchip/irq-ls1x.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/irqchip/irq-ls1x.c b/drivers/irqchip/irq-ls1x.c
index 353111a..409001b 100644
--- a/drivers/irqchip/irq-ls1x.c
+++ b/drivers/irqchip/irq-ls1x.c
@@ -131,7 +131,7 @@ static int __init ls1x_intc_of_init(struct device_node *node,
if (!priv->domain) {
pr_err("ls1x-irq: cannot add IRQ domain\n");
err = -ENOMEM;
- goto out_iounmap;
+ goto out_dispose_irq;
}

err = irq_alloc_domain_generic_chips(priv->domain, 32, 2,
@@ -182,6 +182,8 @@ static int __init ls1x_intc_of_init(struct device_node *node,

out_free_domain:
irq_domain_remove(priv->domain);
+out_dispose_irq:
+ irq_dispose_mapping(parent_irq);
out_iounmap:
iounmap(priv->intc_base);
out_free_priv:
--
2.1.0