From patchwork Wed Jun 24 06:32:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tiezhu Yang X-Patchwork-Id: 11622333 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 119ED13B1 for ; Wed, 24 Jun 2020 06:33:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F0BF821941 for ; Wed, 24 Jun 2020 06:33:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389155AbgFXGdV (ORCPT ); Wed, 24 Jun 2020 02:33:21 -0400 Received: from mail.loongson.cn ([114.242.206.163]:45240 "EHLO loongson.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2389113AbgFXGdU (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--.564S4; Wed, 24 Jun 2020 14:33:10 +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 02/14] irqchip/csky-apb-intc: Fix potential resource leaks Date: Wed, 24 Jun 2020 14:32:35 +0800 Message-Id: <1592980367-1816-3-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--.564S4 X-Coremail-Antispam: 1UD129KBjvJXoW7tF1DWw18XF4Utr1UZFyxZrb_yoW8Gry5pF WUG39I9rZ7tw1xWr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ence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org There exists potential resource leaks in the error path, fix them. Fixes: edff1b4835b7 ("irqchip: add C-SKY APB bus interrupt controller") Signed-off-by: Tiezhu Yang --- drivers/irqchip/irq-csky-apb-intc.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/irqchip/irq-csky-apb-intc.c b/drivers/irqchip/irq-csky-apb-intc.c index 5a2ec43..11a35eb 100644 --- a/drivers/irqchip/irq-csky-apb-intc.c +++ b/drivers/irqchip/irq-csky-apb-intc.c @@ -118,7 +118,8 @@ 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; + ret = -ENOMEM; + goto err_iounmap; } ret = irq_alloc_domain_generic_chips(root_domain, 32, 1, @@ -126,10 +127,17 @@ ck_intc_init_comm(struct device_node *node, struct device_node *parent) IRQ_NOREQUEST | IRQ_NOPROBE | IRQ_NOAUTOEN, 0, 0); if (ret) { pr_err("C-SKY Intc irq_alloc_gc failed.\n"); - return -ENOMEM; + ret = -ENOMEM; + goto err_domain_remove; } return 0; + +err_domain_remove: + irq_domain_remove(root_domain); +err_iounmap: + iounmap(reg_base); + return ret; } static inline bool handle_irq_perbit(struct pt_regs *regs, u32 hwirq,