From patchwork Wed Jun 24 07:45:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tiezhu Yang X-Patchwork-Id: 11622479 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 9A8C192A for ; Wed, 24 Jun 2020 07:45:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8B4922088E for ; Wed, 24 Jun 2020 07:45:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390043AbgFXHpe (ORCPT ); Wed, 24 Jun 2020 03:45:34 -0400 Received: from mail.loongson.cn ([114.242.206.163]:35818 "EHLO loongson.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2389980AbgFXHpW (ORCPT ); Wed, 24 Jun 2020 03:45:22 -0400 Received: from linux.localdomain (unknown [113.200.148.30]) by mail.loongson.cn (Coremail) with SMTP id AQAAf9DxD2qIBPNevCZJAA--.660S12; Wed, 24 Jun 2020 15:45:16 +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 v3 10/14 RESEND] irqchip/nvic: Fix potential resource leaks Date: Wed, 24 Jun 2020 15:45:07 +0800 Message-Id: <1592984711-3130-11-git-send-email-yangtiezhu@loongson.cn> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1592984711-3130-1-git-send-email-yangtiezhu@loongson.cn> References: <1592984711-3130-1-git-send-email-yangtiezhu@loongson.cn> X-CM-TRANSID: AQAAf9DxD2qIBPNevCZJAA--.660S12 X-Coremail-Antispam: 1UD129KBjvJXoW7Kw18Ww17Gr15tw13uFWruFg_yoW8GF1xpF WUW390vr4fG3Wxur95Cw4UZry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1dqw3xlh2x3gn0dqz5rrqw2lrqou0/ Sender: 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: 292ec080491d ("irqchip: Add support for ARMv7-M NVIC") Signed-off-by: Tiezhu Yang --- drivers/irqchip/irq-nvic.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/irqchip/irq-nvic.c b/drivers/irqchip/irq-nvic.c index f747e22..cd17f5d 100644 --- a/drivers/irqchip/irq-nvic.c +++ b/drivers/irqchip/irq-nvic.c @@ -94,7 +94,8 @@ static int __init nvic_of_init(struct device_node *node, if (!nvic_irq_domain) { pr_warn("Failed to allocate irq domain\n"); - return -ENOMEM; + ret = -ENOMEM; + goto err_iounmap; } ret = irq_alloc_domain_generic_chips(nvic_irq_domain, 32, 1, @@ -102,8 +103,7 @@ static int __init nvic_of_init(struct device_node *node, clr, 0, IRQ_GC_INIT_MASK_CACHE); if (ret) { pr_warn("Failed to allocate irq chips\n"); - irq_domain_remove(nvic_irq_domain); - return ret; + goto err_domain_remove; } for (i = 0; i < numbanks; ++i) { @@ -129,5 +129,11 @@ static int __init nvic_of_init(struct device_node *node, writel_relaxed(0, nvic_base + NVIC_IPR + i); return 0; + +err_domain_remove: + irq_domain_remove(nvic_irq_domain); +err_iounmap: + iounmap(nvic_base); + return ret; } IRQCHIP_DECLARE(armv7m_nvic, "arm,armv7m-nvic", nvic_of_init);