From: Tiezhu Yang <yangtiezhu@loongson.cn>
To: Thomas Gleixner <tglx@linutronix.de>,
Jason Cooper <jason@lakedaemon.net>,
Marc Zyngier <maz@kernel.org>
Cc: linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org,
Xuefeng Li <lixuefeng@loongson.cn>
Subject: [PATCH v3 05/14 RESEND] irqchip/davinci-cp-intc: Fix potential resource leaks
Date: Wed, 24 Jun 2020 15:45:02 +0800 [thread overview]
Message-ID: <1592984711-3130-6-git-send-email-yangtiezhu@loongson.cn> (raw)
In-Reply-To: <1592984711-3130-1-git-send-email-yangtiezhu@loongson.cn>
There exists potential resource leaks in the error path, fix them.
Fixes: 0fc3d74cf946 ("irqchip: davinci-cp-intc: move the driver to drivers/irqchip")
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
---
drivers/irqchip/irq-davinci-cp-intc.c | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/drivers/irqchip/irq-davinci-cp-intc.c b/drivers/irqchip/irq-davinci-cp-intc.c
index 276da277..2c2e115 100644
--- a/drivers/irqchip/irq-davinci-cp-intc.c
+++ b/drivers/irqchip/irq-davinci-cp-intc.c
@@ -162,6 +162,7 @@ davinci_cp_intc_do_init(const struct davinci_cp_intc_config *config,
unsigned int num_regs = BITS_TO_LONGS(config->num_irqs);
int offset, irq_base;
void __iomem *req;
+ int ret;
req = request_mem_region(config->reg.start,
resource_size(&config->reg),
@@ -175,7 +176,8 @@ davinci_cp_intc_do_init(const struct davinci_cp_intc_config *config,
resource_size(&config->reg));
if (!davinci_cp_intc_base) {
pr_err("%s: unable to ioremap register range\n", __func__);
- return -EINVAL;
+ ret = -EINVAL;
+ goto err_release;
}
davinci_cp_intc_write(0, DAVINCI_CP_INTC_GLOBAL_ENABLE);
@@ -210,7 +212,8 @@ davinci_cp_intc_do_init(const struct davinci_cp_intc_config *config,
if (irq_base < 0) {
pr_err("%s: unable to allocate interrupt descriptors: %d\n",
__func__, irq_base);
- return irq_base;
+ ret = irq_base;
+ goto err_iounmap;
}
davinci_cp_intc_irq_domain = irq_domain_add_legacy(
@@ -219,7 +222,8 @@ davinci_cp_intc_do_init(const struct davinci_cp_intc_config *config,
if (!davinci_cp_intc_irq_domain) {
pr_err("%s: unable to create an interrupt domain\n", __func__);
- return -EINVAL;
+ ret = -EINVAL;
+ goto err_free_descs;
}
set_handle_irq(davinci_cp_intc_handle_irq);
@@ -228,6 +232,14 @@ davinci_cp_intc_do_init(const struct davinci_cp_intc_config *config,
davinci_cp_intc_write(1, DAVINCI_CP_INTC_GLOBAL_ENABLE);
return 0;
+
+err_free_descs:
+ irq_free_descs(irq_base, config->num_irqs);
+err_iounmap:
+ iounmap(davinci_cp_intc_base);
+err_release:
+ release_mem_region(config->reg.start, resource_size(&config->reg));
+ return ret;
}
int __init davinci_cp_intc_init(const struct davinci_cp_intc_config *config)
--
2.1.0
next prev parent reply other threads:[~2020-06-24 7:46 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-24 7:44 [PATCH v3 00/14 RESEND] irqchip: Fix potential resource leaks Tiezhu Yang
2020-06-24 7:44 ` [PATCH v3 01/14 RESEND] irqchip/ath79-misc: " Tiezhu Yang
2020-06-24 7:44 ` [PATCH v3 02/14 RESEND] irqchip/csky-apb-intc: " Tiezhu Yang
2020-06-24 7:45 ` [PATCH v3 03/14 RESEND] irqchip/csky-mpintc: " Tiezhu Yang
2020-06-24 7:45 ` [PATCH v3 04/14 RESEND] irqchip/davinci-aintc: " Tiezhu Yang
2020-06-24 7:45 ` Tiezhu Yang [this message]
2020-06-24 7:45 ` [PATCH v3 06/14 RESEND] irqchip/digicolor: " Tiezhu Yang
2020-06-24 7:45 ` [PATCH v3 07/14 RESEND] irqchip/dw-apb-ictl: " Tiezhu Yang
2020-06-24 7:45 ` [PATCH v3 08/14 RESEND] irqchip/ls1x: " Tiezhu Yang
2020-06-24 7:45 ` [PATCH v3 09/14 RESEND] irqchip/mscc-ocelot: " Tiezhu Yang
2020-06-24 7:45 ` [PATCH v3 10/14 RESEND] irqchip/nvic: " Tiezhu Yang
2020-06-24 7:45 ` [PATCH v3 11/14 RESEND] irqchip/omap-intc: Fix potential resource leak Tiezhu Yang
2020-06-24 8:30 ` [PATCH v3 00/14 RESEND] irqchip: Fix potential resource leaks Marc Zyngier
2020-06-24 9:02 ` Tiezhu Yang
2020-06-24 11:48 ` Tiezhu Yang
2020-06-24 11:52 ` Marc Zyngier
2020-06-28 11:25 ` Aleksandar Markovic
2020-06-28 12:06 ` Marc Zyngier
2020-06-28 12:48 ` Aleksandar Markovic
2020-06-28 16:55 ` Marc Zyngier
2020-06-28 17:00 ` Aleksandar Markovic
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1592984711-3130-6-git-send-email-yangtiezhu@loongson.cn \
--to=yangtiezhu@loongson.cn \
--cc=jason@lakedaemon.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@vger.kernel.org \
--cc=lixuefeng@loongson.cn \
--cc=maz@kernel.org \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).