From patchwork Wed Jun 24 06:32:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tiezhu Yang X-Patchwork-Id: 11622337 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 83B4160D for ; Wed, 24 Jun 2020 06:33:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 756082088E for ; Wed, 24 Jun 2020 06:33:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389163AbgFXGdV (ORCPT ); Wed, 24 Jun 2020 02:33:21 -0400 Received: from mail.loongson.cn ([114.242.206.163]:45210 "EHLO loongson.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2389063AbgFXGdU (ORCPT ); Wed, 24 Jun 2020 02:33:20 -0400 Received: from linux.localdomain (unknown [113.200.148.30]) by mail.loongson.cn (Coremail) with SMTP id AQAAf9Dxj9+j8_Je2R5JAA--.564S15; Wed, 24 Jun 2020 14:33:15 +0800 (CST) From: Tiezhu Yang To: Thomas Gleixner , Jason Cooper , Marc Zyngier Cc: linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, Xuefeng Li Subject: [PATCH v2 13/14] irqchip/s3c24xx: Fix potential resource leaks Date: Wed, 24 Jun 2020 14:32:46 +0800 Message-Id: <1592980367-1816-14-git-send-email-yangtiezhu@loongson.cn> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1592980367-1816-1-git-send-email-yangtiezhu@loongson.cn> References: <1592980367-1816-1-git-send-email-yangtiezhu@loongson.cn> X-CM-TRANSID: AQAAf9Dxj9+j8_Je2R5JAA--.564S15 X-Coremail-Antispam: 1UD129KBjvJXoW7uw1rKFyrKF1xXFW5Kr13XFb_yoW8WrWrpF WkW390gr48Gay7Wr4fKr4DZ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ender: linux-mips-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org There exists potential resource leaks in the error path, fix them. Fixes: f0774d41da0e ("irqchip: s3c24xx: add devicetree support") Signed-off-by: Tiezhu Yang Reported-by: kernel test robot Reported-by: kernel test robot --- drivers/irqchip/irq-s3c24xx.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/drivers/irqchip/irq-s3c24xx.c b/drivers/irqchip/irq-s3c24xx.c index d2031fe..ef5d645 100644 --- a/drivers/irqchip/irq-s3c24xx.c +++ b/drivers/irqchip/irq-s3c24xx.c @@ -1239,7 +1239,8 @@ static int __init s3c_init_intc_of(struct device_node *np, &s3c24xx_irq_ops_of, NULL); if (!domain) { pr_err("irq: could not create irq-domain\n"); - return -EINVAL; + ret = -EINVAL; + goto out_iounmap; } for (i = 0; i < num_ctrl; i++) { @@ -1248,15 +1249,17 @@ static int __init s3c_init_intc_of(struct device_node *np, pr_debug("irq: found controller %s\n", ctrl->name); intc = kzalloc(sizeof(struct s3c_irq_intc), GFP_KERNEL); - if (!intc) - return -ENOMEM; + if (!intc) { + ret = -ENOMEM; + goto out_domain_remove; + } intc->domain = domain; intc->irqs = kcalloc(32, sizeof(struct s3c_irq_data), GFP_KERNEL); if (!intc->irqs) { - kfree(intc); - return -ENOMEM; + ret = -ENOMEM; + goto out_free; } if (ctrl->parent) { @@ -1285,6 +1288,13 @@ static int __init s3c_init_intc_of(struct device_node *np, set_handle_irq(s3c24xx_handle_irq); return 0; + +out_free: + kfree(intc); +out_domain_remove: + irq_domain_remove(domain); +out_iounmap: + iounmap(reg_base); } static struct s3c24xx_irq_of_ctrl s3c2410_ctrl[] = {