* Re: [PATCH v3 04/14] irqchip/davinci-aintc: Fix potential resource leaks
@ 2020-06-24 13:12 Markus Elfring
2020-06-28 3:23 ` Tiezhu Yang
0 siblings, 1 reply; 3+ messages in thread
From: Markus Elfring @ 2020-06-24 13:12 UTC (permalink / raw)
To: Tiezhu Yang, linux-mips
Cc: kernel-janitors, linux-kernel, Jason Cooper, Marc Zyngier,
Thomas Gleixner, Xuefeng Li
> There exists potential resource leaks in the error path, fix them.
Would you like to reconsider this change description?
https://lore.kernel.org/linux-mips/be3acb13-2963-ddf1-a867-7e30fd23a0b4@loongson.cn/
https://lkml.org/lkml/2020/6/24/498
…
> +++ b/drivers/irqchip/irq-davinci-aintc.c
…
> @@ -160,4 +160,13 @@ void __init davinci_aintc_init(const struct davinci_aintc_config *config)
> irq_base + irq_off, 32);
>
> set_handle_irq(davinci_aintc_handle_irq);
> +
> +err_domain_remove:
…
Are you sure that you would to like to release the allocated system resources
always in this function implementation?
Otherwise, I suggest to add a return statement before the source code section
for the desired exception handling.
Regards,
Markus
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v3 04/14] irqchip/davinci-aintc: Fix potential resource leaks
2020-06-24 13:12 [PATCH v3 04/14] irqchip/davinci-aintc: Fix potential resource leaks Markus Elfring
@ 2020-06-28 3:23 ` Tiezhu Yang
0 siblings, 0 replies; 3+ messages in thread
From: Tiezhu Yang @ 2020-06-28 3:23 UTC (permalink / raw)
To: Markus Elfring, linux-mips
Cc: kernel-janitors, linux-kernel, Jason Cooper, Marc Zyngier,
Thomas Gleixner, Xuefeng Li
On 06/24/2020 09:12 PM, Markus Elfring wrote:
>> There exists potential resource leaks in the error path, fix them.
> Would you like to reconsider this change description?
> https://lore.kernel.org/linux-mips/be3acb13-2963-ddf1-a867-7e30fd23a0b4@loongson.cn/
> https://lkml.org/lkml/2020/6/24/498
>
>
> …
>> +++ b/drivers/irqchip/irq-davinci-aintc.c
> …
>> @@ -160,4 +160,13 @@ void __init davinci_aintc_init(const struct davinci_aintc_config *config)
>> irq_base + irq_off, 32);
>>
>> set_handle_irq(davinci_aintc_handle_irq);
>> +
>> +err_domain_remove:
> …
>
> Are you sure that you would to like to release the allocated system resources
> always in this function implementation?
>
> Otherwise, I suggest to add a return statement before the source code section
> for the desired exception handling.
Thank you! Sorry for the late reply.
I will add a return statement.
>
> Regards,
> Markus
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v3 00/14] irqchip: Fix potential resource leaks
@ 2020-06-24 7:29 Tiezhu Yang
2020-06-24 7:29 ` [PATCH v3 04/14] irqchip/davinci-aintc: " Tiezhu Yang
0 siblings, 1 reply; 3+ messages in thread
From: Tiezhu Yang @ 2020-06-24 7:29 UTC (permalink / raw)
To: Thomas Gleixner, Jason Cooper, Marc Zyngier, Rob Herring
Cc: Huacai Chen, Jiaxun Yang, linux-kernel, devicetree, linux-mips,
Xuefeng Li
When I test the irqchip code of Loongson, I read the related code of other
chips in drivers/irqchip and I find some potential resource leaks in the
error path, I think it is better to fix them.
v2:
- Split the first patch into a new patch series which
includes small patches and add "Fixes" tag
- Use "goto" label to handle error path in some patches
v3:
- Add missed variable "ret" in the patch #5 and #13,
sorry for that
Tiezhu Yang (14):
irqchip/ath79-misc: Fix potential resource leaks
irqchip/csky-apb-intc: Fix potential resource leaks
irqchip/csky-mpintc: Fix potential resource leaks
irqchip/davinci-aintc: Fix potential resource leaks
irqchip/davinci-cp-intc: Fix potential resource leaks
irqchip/digicolor: Fix potential resource leaks
irqchip/dw-apb-ictl: Fix potential resource leaks
irqchip/ls1x: Fix potential resource leaks
irqchip/mscc-ocelot: Fix potential resource leaks
irqchip/nvic: Fix potential resource leaks
irqchip/omap-intc: Fix potential resource leak
irqchip/riscv-intc: Fix potential resource leak
irqchip/s3c24xx: Fix potential resource leaks
irqchip/xilinx-intc: Fix potential resource leak
drivers/irqchip/irq-ath79-misc.c | 14 +++++++++++---
drivers/irqchip/irq-csky-apb-intc.c | 12 ++++++++++--
drivers/irqchip/irq-csky-mpintc.c | 26 ++++++++++++++++++++------
drivers/irqchip/irq-davinci-aintc.c | 17 +++++++++++++----
drivers/irqchip/irq-davinci-cp-intc.c | 18 +++++++++++++++---
drivers/irqchip/irq-digicolor.c | 14 +++++++++++---
drivers/irqchip/irq-dw-apb-ictl.c | 11 ++++++++---
drivers/irqchip/irq-ls1x.c | 4 +++-
drivers/irqchip/irq-mscc-ocelot.c | 6 ++++--
drivers/irqchip/irq-nvic.c | 12 +++++++++---
drivers/irqchip/irq-omap-intc.c | 4 +++-
drivers/irqchip/irq-riscv-intc.c | 1 +
drivers/irqchip/irq-s3c24xx.c | 23 +++++++++++++++++------
drivers/irqchip/irq-xilinx-intc.c | 4 +++-
14 files changed, 128 insertions(+), 38 deletions(-)
--
2.1.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v3 04/14] irqchip/davinci-aintc: Fix potential resource leaks
2020-06-24 7:29 [PATCH v3 00/14] irqchip: " Tiezhu Yang
@ 2020-06-24 7:29 ` Tiezhu Yang
0 siblings, 0 replies; 3+ messages in thread
From: Tiezhu Yang @ 2020-06-24 7:29 UTC (permalink / raw)
To: Thomas Gleixner, Jason Cooper, Marc Zyngier, Rob Herring
Cc: Huacai Chen, Jiaxun Yang, linux-kernel, devicetree, linux-mips,
Xuefeng Li
There exists potential resource leaks in the error path, fix them.
Fixes: 0145beed9d26 ("irqchip: davinci-aintc: move the driver to drivers/irqchip")
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
---
drivers/irqchip/irq-davinci-aintc.c | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/drivers/irqchip/irq-davinci-aintc.c b/drivers/irqchip/irq-davinci-aintc.c
index 810ccc4..12db502 100644
--- a/drivers/irqchip/irq-davinci-aintc.c
+++ b/drivers/irqchip/irq-davinci-aintc.c
@@ -96,7 +96,7 @@ void __init davinci_aintc_init(const struct davinci_aintc_config *config)
resource_size(&config->reg));
if (!davinci_aintc_base) {
pr_err("%s: unable to ioremap register range\n", __func__);
- return;
+ goto err_release;
}
/* Clear all interrupt requests */
@@ -133,7 +133,7 @@ void __init davinci_aintc_init(const struct davinci_aintc_config *config)
if (irq_base < 0) {
pr_err("%s: unable to allocate interrupt descriptors: %d\n",
__func__, irq_base);
- return;
+ goto err_iounmap;
}
davinci_aintc_irq_domain = irq_domain_add_legacy(NULL,
@@ -141,7 +141,7 @@ void __init davinci_aintc_init(const struct davinci_aintc_config *config)
&irq_domain_simple_ops, NULL);
if (!davinci_aintc_irq_domain) {
pr_err("%s: unable to create interrupt domain\n", __func__);
- return;
+ goto err_free_descs;
}
ret = irq_alloc_domain_generic_chips(davinci_aintc_irq_domain, 32, 1,
@@ -150,7 +150,7 @@ void __init davinci_aintc_init(const struct davinci_aintc_config *config)
if (ret) {
pr_err("%s: unable to allocate generic irq chips for domain\n",
__func__);
- return;
+ goto err_domain_remove;
}
for (irq_off = 0, reg_off = 0;
@@ -160,4 +160,13 @@ void __init davinci_aintc_init(const struct davinci_aintc_config *config)
irq_base + irq_off, 32);
set_handle_irq(davinci_aintc_handle_irq);
+
+err_domain_remove:
+ irq_domain_remove(davinci_aintc_irq_domain);
+err_free_descs:
+ irq_free_descs(irq_base, config->num_irqs);
+err_iounmap:
+ iounmap(davinci_aintc_base);
+err_release:
+ release_mem_region(config->reg.start, resource_size(&config->reg));
}
--
2.1.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-06-28 3:23 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-24 13:12 [PATCH v3 04/14] irqchip/davinci-aintc: Fix potential resource leaks Markus Elfring
2020-06-28 3:23 ` Tiezhu Yang
-- strict thread matches above, loose matches on Subject: below --
2020-06-24 7:29 [PATCH v3 00/14] irqchip: " Tiezhu Yang
2020-06-24 7:29 ` [PATCH v3 04/14] irqchip/davinci-aintc: " Tiezhu Yang
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).