Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp457586ybt; Wed, 1 Jul 2020 02:36:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxp6r5uuciXdcH84crCfJNRAohq8a/NE+r1py8GYp8nAcK/UFJhL1jpi6wUWUb0ZZwkjHtu X-Received: by 2002:a17:906:2a91:: with SMTP id l17mr22719759eje.539.1593596176153; Wed, 01 Jul 2020 02:36:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593596176; cv=none; d=google.com; s=arc-20160816; b=U38T15YrHXlz+c9NodcjUkm9RhAdYs83YLQqKmPZakyP90R72bJR+pQQPb3kJCMrSu T0xr7nPbbb0Xv2fwpEa7oGKsKsWhuphzHf/37i8VOUW7WRpPgNTaEbRI1okvapNhjqGS byAiTSwiYX68m3PATwd+6OROsCK+fDvWwjbCHTuF5nT8Jhb/fBqBRuWmf5TkCGR7crQ+ 7OqoGZ2RgxCzcxd68FFAhM+X/sEGQ+tGtaQ9v5yo3yzjfqRJXyDPVEfA+8pyIj8aeP3G 2Wb9QqQvAomj+aql1GEjSizcEvyFpWNV3rYODbyCNdOGgGsqsM2RCaW4CKomXRujX3OM OHWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:cc:references:to :subject; bh=WbDn4RlIcrrqYThD7df+Gzcy9yq9W3lTxofQEM+DnDk=; b=mdrTG7voYt/UODd4jspvgknpoBpL+oSSMK4nwfn8Hj1PJ9vexAh27xC6VRCfMCXoBf TeGOQ2XWK2018C05F20C239kjfrut2d8dlydHw02c5go8PkGPl6u64e3ZqEDrRU31hff W6OFP7Z2i40L+tBNldK/8ooEnTo0WXuXuPmWTb/SiTzX0O7UvZr+UB2kDDcx0gx4dztG C23agbzBXWXLlhyIS19yfFXnGR71iNHfa6Ova32aRPGLcHpvYzGiOzhF1i0gRkUF9e6D uVI/IetoUaptpQfLj+HkPpkUZeC5VqqTvXcn4plsTxmTI3lj6HqlUifSEvsm7CztZSvC 3sSw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a7si3403057eds.485.2020.07.01.02.35.52; Wed, 01 Jul 2020 02:36:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729395AbgGAJfo (ORCPT + 99 others); Wed, 1 Jul 2020 05:35:44 -0400 Received: from mail.loongson.cn ([114.242.206.163]:33250 "EHLO loongson.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726715AbgGAJfn (ORCPT ); Wed, 1 Jul 2020 05:35:43 -0400 Received: from [10.130.0.52] (unknown [113.200.148.30]) by mail.loongson.cn (Coremail) with SMTP id AQAAf9Dx72nnWPxeqKBNAA--.1635S3; Wed, 01 Jul 2020 17:35:36 +0800 (CST) Subject: Re: [PATCH v4 02/14] irqchip/csky-apb-intc: Fix potential resource leaks To: Markus Elfring , Thomas Gleixner , Jason Cooper , Marc Zyngier , Guo Ren , linux-csky@vger.kernel.org References: <1593569786-11500-1-git-send-email-yangtiezhu@loongson.cn> <1593569786-11500-3-git-send-email-yangtiezhu@loongson.cn> <564ffff9-6043-7191-2458-f425dd8d0c11@web.de> Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org From: Tiezhu Yang Message-ID: <1a0e007a-db94-501b-4ab9-0bb479ec093b@loongson.cn> Date: Wed, 1 Jul 2020 17:35:35 +0800 User-Agent: Mozilla/5.0 (X11; Linux mips64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <564ffff9-6043-7191-2458-f425dd8d0c11@web.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-CM-TRANSID: AQAAf9Dx72nnWPxeqKBNAA--.1635S3 X-Coremail-Antispam: 1UD129KBjvJXoW7tF1DGr4DWw1UArWkGryfJFb_yoW8Cw15pF WUXrZI9rZ7t3W7Wrn7ZF97X3s8u347KFZFy34Skas7Zrn8Crn8CrW8AFnYvFn8Cw1xWa1F vFs5Aa4rCa15AFDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUvqb7Iv0xC_KF4lb4IE77IF4wAFF20E14v26r4j6ryUM7CY07I2 0VC2zVCF04k26cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rw A2F7IY1VAKz4vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Gr0_Xr1l84ACjcxK6xII jxv20xvEc7CjxVAFwI0_Cr0_Gr1UM28EF7xvwVC2z280aVAFwI0_Cr1j6rxdM28EF7xvwV C2z280aVCY1x0267AKxVW0oVCq3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC 0VAKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWUGVWUXwAv7VC2z280aVAFwI0_Gr0_Cr 1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcVAKI48JMxk0xIA0c2IEe2xFo4CEbIxvr21l c2xSY4AK67AK6r4fMxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I 0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWU tVW8ZwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r1j6r1xMIIF0xvE2Ix0cI8IcV CY1x0267AKxVW8JVWxJwCI42IY6xAIw20EY4v20xvaj40_Wr1j6rW3Jr1lIxAIcVC2z280 aVAFwI0_Gr0_Cr1lIxAIcVC2z280aVCY1x0267AKxVW8Jr0_Cr1UYxBIdaVFxhVjvjDU0x ZFpf9x07jriSQUUUUU= X-CM-SenderInfo: p1dqw3xlh2x3gn0dqz5rrqw2lrqou0/ Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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