[PATCH v5 02/14] irqchip/csky-apb-intc: Fix potential resource leaks

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


In the function ck_intc_init_comm(), system resources "reg_base" and
"root_domain" were not released in two error cases. Thus add jump
targets for the completion of the desired exception handling.

Fixes: edff1b4835b7 ("irqchip: add C-SKY APB bus interrupt controller")
Signed-off-by: Tiezhu Yang <yangtiezhu@xxxxxxxxxxx>
---
drivers/irqchip/irq-csky-apb-intc.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/irqchip/irq-csky-apb-intc.c b/drivers/irqchip/irq-csky-apb-intc.c
index 5a2ec43..66aeb84 100644
--- a/drivers/irqchip/irq-csky-apb-intc.c
+++ b/drivers/irqchip/irq-csky-apb-intc.c
@@ -118,7 +118,8 @@ ck_intc_init_comm(struct device_node *node, struct device_node *parent)
&irq_generic_chip_ops, NULL);
if (!root_domain) {
pr_err("C-SKY Intc irq_domain_add failed.\n");
- return -ENOMEM;
+ ret = -ENOMEM;
+ goto err_iounmap;
}

ret = irq_alloc_domain_generic_chips(root_domain, 32, 1,
@@ -126,10 +127,16 @@ ck_intc_init_comm(struct device_node *node, struct device_node *parent)
IRQ_NOREQUEST | IRQ_NOPROBE | IRQ_NOAUTOEN, 0, 0);
if (ret) {
pr_err("C-SKY Intc irq_alloc_gc failed.\n");
- return -ENOMEM;
+ goto err_domain_remove;
}

return 0;
+
+err_domain_remove:
+ irq_domain_remove(root_domain);
+err_iounmap:
+ iounmap(reg_base);
+ return ret;
}

static inline bool handle_irq_perbit(struct pt_regs *regs, u32 hwirq,
--
2.1.0