kernel-janitors.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tiezhu Yang <yangtiezhu@loongson.cn>
To: Markus Elfring <Markus.Elfring@web.de>,
	Thomas Gleixner <tglx@linutronix.de>,
	Jason Cooper <jason@lakedaemon.net>,
	Marc Zyngier <maz@kernel.org>, Guo Ren <guoren@kernel.org>,
	linux-csky@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH v4 02/14] irqchip/csky-apb-intc: Fix potential resource leaks
Date: Wed, 01 Jul 2020 09:35:35 +0000	[thread overview]
Message-ID: <1a0e007a-db94-501b-4ab9-0bb479ec093b@loongson.cn> (raw)
In-Reply-To: <564ffff9-6043-7191-2458-f425dd8d0c11@web.de>

On 07/01/2020 04:40 PM, Markus Elfring wrote:
>> … were not released in a few error cases. …
> Another small wording adjustment:
>    … in two error cases. …

OK

>
>
> …
>> +++ b/drivers/irqchip/irq-csky-apb-intc.c
> …
>> @@ -126,10 +127,17 @@ ck_intc_init_comm(struct device_node *node, struct device_node *parent)
> …
>> +err_iounmap:
>> +	iounmap(reg_base);
>> +	return ret;
>>   }
> …
>
> How do you think about to use the statement “return -ENOMEM;”?

OK

> Can the local variable “ret” be omitted in this function implementation?

If remove the local variable "ret",  it will look like this:

diff --git a/drivers/irqchip/irq-csky-apb-intc.c 
b/drivers/irqchip/irq-csky-apb-intc.c
index 5a2ec43..7e56657 100644
--- a/drivers/irqchip/irq-csky-apb-intc.c
+++ b/drivers/irqchip/irq-csky-apb-intc.c
@@ -101,8 +101,6 @@ static inline void setup_irq_channel(u32 magic, void 
__iomem *reg_addr)
  static int __init
  ck_intc_init_comm(struct device_node *node, struct device_node *parent)
  {
-       int ret;
-
         if (parent) {
                 pr_err("C-SKY Intc not a root irq controller\n");
                 return -EINVAL;
@@ -118,18 +116,23 @@ 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;
+               goto err_iounmap;
         }

-       ret = irq_alloc_domain_generic_chips(root_domain, 32, 1,
+       if (irq_alloc_domain_generic_chips(root_domain, 32, 1,
                         "csky_intc", handle_level_irq,
-                       IRQ_NOREQUEST | IRQ_NOPROBE | IRQ_NOAUTOEN, 0, 0);
-       if (ret) {
+                       IRQ_NOREQUEST | IRQ_NOPROBE | IRQ_NOAUTOEN, 0, 0)) {
                 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 -ENOMEM;
  }

>
> Regards,
> Markus

  reply	other threads:[~2020-07-01  9:35 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1593569786-11500-1-git-send-email-yangtiezhu@loongson.cn>
     [not found] ` <1593569786-11500-4-git-send-email-yangtiezhu@loongson.cn>
2020-07-01  7:49   ` [PATCH v4 03/14] irqchip/csky-mpintc: Fix potential resource leaks Markus Elfring
2020-07-01  9:23     ` Tiezhu Yang
     [not found] ` <1593569786-11500-5-git-send-email-yangtiezhu@loongson.cn>
2020-07-01  8:15   ` [PATCH v4 04/14] irqchip/davinci-aintc: " Markus Elfring
2020-07-01  9:19     ` Tiezhu Yang
     [not found] ` <1593569786-11500-3-git-send-email-yangtiezhu@loongson.cn>
2020-07-01  8:40   ` [PATCH v4 02/14] irqchip/csky-apb-intc: " Markus Elfring
2020-07-01  9:35     ` Tiezhu Yang [this message]
2020-07-01 13:04       ` Markus Elfring
2020-07-02  1:18         ` Tiezhu Yang
2020-07-02  7:19           ` Markus Elfring
2020-07-02  7:19           ` Markus Elfring
2020-07-02  8:05             ` Tiezhu Yang
2020-07-02 11:53               ` Tiezhu Yang
2020-07-02 12:24                 ` [v4 " Markus Elfring
2020-07-02 12:35                   ` Tiezhu Yang
2020-07-02 15:00       ` [PATCH v4 " Dan Carpenter
     [not found] ` <1593569786-11500-12-git-send-email-yangtiezhu@loongson.cn>
2020-07-01  9:14   ` [PATCH v4 11/14] irqchip/omap-intc: Fix potential resource leak Markus Elfring
2020-07-01  9:40     ` Tiezhu Yang
     [not found] ` <1593569786-11500-13-git-send-email-yangtiezhu@loongson.cn>
2020-07-01  9:30   ` [PATCH v4 12/14] irqchip/riscv-intc: " Markus Elfring
     [not found] ` <1593569786-11500-15-git-send-email-yangtiezhu@loongson.cn>
2020-07-01  9:42   ` [PATCH v4 14/14] irqchip/xilinx-intc: " Markus Elfring
2020-07-01  9:58     ` Tiezhu Yang

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=1a0e007a-db94-501b-4ab9-0bb479ec093b@loongson.cn \
    --to=yangtiezhu@loongson.cn \
    --cc=Markus.Elfring@web.de \
    --cc=guoren@kernel.org \
    --cc=jason@lakedaemon.net \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-csky@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --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).