* Re: [PATCH v3 03/14] irqchip/csky-mpintc: Fix potential resource leaks
@ 2020-06-24 11:43 Markus Elfring
2020-06-24 12:07 ` Tiezhu Yang
0 siblings, 1 reply; 4+ messages in thread
From: Markus Elfring @ 2020-06-24 11:43 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.
I suggest to improve this change description.
How do you think about another wording variant?
Specific system resources were not released in a few error cases.
Thus add jump targets for the completion of the desired exception handling.
…
+++ b/drivers/irqchip/irq-csky-mpintc.c
@@ -247,8 +247,10 @@ csky_mpintc_init(struct device_node *node, struct device_node *parent)
…
INTCG_base = ioremap(mfcr("cr<31, 14>"),
INTCL_SIZE*nr_cpu_ids + INTCG_SIZE);
See also:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/coding-style.rst?id=3e08a95294a4fb3702bb3d35ed08028433c37fe6#n257
…
+ if (INTCG_base == NULL) {
Would you like to use the following code variant?
See also:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/scripts/checkpatch.pl?id=3e08a95294a4fb3702bb3d35ed08028433c37fe6#n5756
+ if (!INTCG_base) {
…
> @@ -270,12 +274,22 @@ csky_mpintc_init(struct device_node *node, struct device_node *parent)
>
> #ifdef CONFIG_SMP
> ipi_irq = irq_create_mapping(root_domain, IPI_IRQ);
…
> + if (!ipi_irq) {
> + ret = -EIO;
> + goto err_domain_remove;
> + }
…
Can the function call “irq_domain_remove(root_domain)” become relevant
only if the preprocessor symbol “CONFIG_SMP” was defined?
Regards,
Markus
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH v3 03/14] irqchip/csky-mpintc: Fix potential resource leaks
2020-06-24 11:43 [PATCH v3 03/14] irqchip/csky-mpintc: Fix potential resource leaks Markus Elfring
@ 2020-06-24 12:07 ` Tiezhu Yang
2020-06-24 12:21 ` [v3 " Markus Elfring
0 siblings, 1 reply; 4+ messages in thread
From: Tiezhu Yang @ 2020-06-24 12:07 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 07:43 PM, Markus Elfring wrote:
>> There exists potential resource leaks in the error path, fix them.
> I suggest to improve this change description.
> How do you think about another wording variant?
>
> Specific system resources were not released in a few error cases.
> Thus add jump targets for the completion of the desired exception handling.
OK, thank you, it looks good to me.
Maybe I can use this description for other patches of this series.
>
>
> …
> +++ b/drivers/irqchip/irq-csky-mpintc.c
> @@ -247,8 +247,10 @@ csky_mpintc_init(struct device_node *node, struct device_node *parent)
> …
> INTCG_base = ioremap(mfcr("cr<31, 14>"),
> INTCL_SIZE*nr_cpu_ids + INTCG_SIZE);
>
> See also:
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/coding-style.rst?id=3e08a95294a4fb3702bb3d35ed08028433c37fe6#n257
>
>
> …
> + if (INTCG_base == NULL) {
>
>
> Would you like to use the following code variant?
>
> See also:
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/scripts/checkpatch.pl?id=3e08a95294a4fb3702bb3d35ed08028433c37fe6#n5756
>
> + if (!INTCG_base) {
>
>
> …
>> @@ -270,12 +274,22 @@ csky_mpintc_init(struct device_node *node, struct device_node *parent)
>>
>> #ifdef CONFIG_SMP
>> ipi_irq = irq_create_mapping(root_domain, IPI_IRQ);
> …
>> + if (!ipi_irq) {
>> + ret = -EIO;
>> + goto err_domain_remove;
>> + }
> …
>
> Can the function call “irq_domain_remove(root_domain)” become relevant
> only if the preprocessor symbol “CONFIG_SMP” was defined?
OK, I will do it in the next version.
>
> Regards,
> Markus
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [v3 03/14] irqchip/csky-mpintc: Fix potential resource leaks
2020-06-24 12:07 ` Tiezhu Yang
@ 2020-06-24 12:21 ` Markus Elfring
0 siblings, 0 replies; 4+ messages in thread
From: Markus Elfring @ 2020-06-24 12:21 UTC (permalink / raw)
To: Tiezhu Yang, linux-mips
Cc: kernel-janitors, linux-kernel, Jason Cooper, Marc Zyngier,
Thomas Gleixner, Xuefeng Li
>> How do you think about another wording variant?
>>
>> Specific system resources were not released in a few error cases.
>> Thus add jump targets for the completion of the desired exception handling.
>
> OK, thank you, it looks good to me.
Thanks for your positive feedback.
> Maybe I can use this description for other patches of this series.
Would you like to make any of the affected commit messages more “specific”?
Regards,
Markus
^ permalink raw reply [flat|nested] 4+ 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 03/14] irqchip/csky-mpintc: " Tiezhu Yang
0 siblings, 1 reply; 4+ 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] 4+ messages in thread* [PATCH v3 03/14] irqchip/csky-mpintc: 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; 4+ 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: d8a5f5f79122 ("irqchip: add C-SKY SMP interrupt controller")
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
---
drivers/irqchip/irq-csky-mpintc.c | 26 ++++++++++++++++++++------
1 file changed, 20 insertions(+), 6 deletions(-)
diff --git a/drivers/irqchip/irq-csky-mpintc.c b/drivers/irqchip/irq-csky-mpintc.c
index a1534ed..c195e24 100644
--- a/drivers/irqchip/irq-csky-mpintc.c
+++ b/drivers/irqchip/irq-csky-mpintc.c
@@ -247,8 +247,10 @@ csky_mpintc_init(struct device_node *node, struct device_node *parent)
if (INTCG_base == NULL) {
INTCG_base = ioremap(mfcr("cr<31, 14>"),
INTCL_SIZE*nr_cpu_ids + INTCG_SIZE);
- if (INTCG_base == NULL)
- return -EIO;
+ if (INTCG_base == NULL) {
+ ret = -EIO;
+ goto err_free;
+ }
INTCL_base = INTCG_base + INTCG_SIZE;
@@ -257,8 +259,10 @@ csky_mpintc_init(struct device_node *node, struct device_node *parent)
root_domain = irq_domain_add_linear(node, nr_irq, &csky_irqdomain_ops,
NULL);
- if (!root_domain)
- return -ENXIO;
+ if (!root_domain) {
+ ret = -ENXIO;
+ goto err_iounmap;
+ }
/* for every cpu */
for_each_present_cpu(cpu) {
@@ -270,12 +274,22 @@ csky_mpintc_init(struct device_node *node, struct device_node *parent)
#ifdef CONFIG_SMP
ipi_irq = irq_create_mapping(root_domain, IPI_IRQ);
- if (!ipi_irq)
- return -EIO;
+ if (!ipi_irq) {
+ ret = -EIO;
+ goto err_domain_remove;
+ }
set_send_ipi(&csky_mpintc_send_ipi, ipi_irq);
#endif
return 0;
+
+err_domain_remove:
+ irq_domain_remove(root_domain);
+err_iounmap:
+ iounmap(INTCG_base);
+err_free:
+ kfree(__trigger);
+ return ret;
}
IRQCHIP_DECLARE(csky_mpintc, "csky,mpintc", csky_mpintc_init);
--
2.1.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-06-24 12:21 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-06-24 11:43 [PATCH v3 03/14] irqchip/csky-mpintc: Fix potential resource leaks Markus Elfring
2020-06-24 12:07 ` Tiezhu Yang
2020-06-24 12:21 ` [v3 " Markus Elfring
-- 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 03/14] irqchip/csky-mpintc: " Tiezhu Yang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox