[PATCH v2 01/14] irqchip/ath79-misc: Fix potential resource leaks

From: Tiezhu Yang
Date: Wed Jun 24 2020 - 02:33:45 EST


There exists potential resource leaks in the error path, fix them.

Fixes: 07ba4b061a79 ("irqchip/ath79-misc: Move the MISC driver from arch/mips/ath79/")
Signed-off-by: Tiezhu Yang <yangtiezhu@xxxxxxxxxxx>
---
drivers/irqchip/irq-ath79-misc.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/drivers/irqchip/irq-ath79-misc.c b/drivers/irqchip/irq-ath79-misc.c
index 3d641bb..53e0c50 100644
--- a/drivers/irqchip/irq-ath79-misc.c
+++ b/drivers/irqchip/irq-ath79-misc.c
@@ -133,7 +133,7 @@ static int __init ath79_misc_intc_of_init(
{
struct irq_domain *domain;
void __iomem *base;
- int irq;
+ int irq, ret;

irq = irq_of_parse_and_map(node, 0);
if (!irq) {
@@ -144,18 +144,26 @@ static int __init ath79_misc_intc_of_init(
base = of_iomap(node, 0);
if (!base) {
pr_err("Failed to get MISC IRQ registers\n");
- return -ENOMEM;
+ ret = -ENOMEM;
+ goto err_irq_dispose;
}

domain = irq_domain_add_linear(node, ATH79_MISC_IRQ_COUNT,
&misc_irq_domain_ops, base);
if (!domain) {
pr_err("Failed to add MISC irqdomain\n");
- return -EINVAL;
+ ret = -EINVAL;
+ goto err_iounmap;
}

ath79_misc_intc_domain_init(domain, irq);
return 0;
+
+err_iounmap:
+ iounmap(base);
+err_irq_dispose:
+ irq_dispose_mapping(irq);
+ return ret;
}

static int __init ar7100_misc_intc_of_init(
--
2.1.0