Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp228808ybt; Tue, 30 Jun 2020 19:23:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx4PkyUMXyFXig+ZSB6CCy6xD7u2MIdQtqfc22G66jG8cxta/uaU5+M/cd10I9nIrtn1Dni X-Received: by 2002:a50:fa0c:: with SMTP id b12mr27052032edq.226.1593570191808; Tue, 30 Jun 2020 19:23:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593570191; cv=none; d=google.com; s=arc-20160816; b=YqTMa0Sd2vqnwTbg9vPRQfVwXYpREkZ+NzhUmw7PqEbLeVIkeMjXZRzveDzLdoh7aj UzivIeAobRm3AtnPddotcgz6QKTc0qBkLShW3K5Y43OmlsDxU56ayc8XcMNvLZLEAx+/ omSljewnjaj7BXPEsqUypgcPWUaaNMndxoTQI4FpiPhAySVk7yOFIsdwWilDt1YrVQ8t qERRd64CRIaYLwfJ2RsxjqYyRsyzzXuYrHDXldtFjvEakQg04yw1MuL7RTAYEPoS06tK /RpXvJbIP8qSIqlm3bNkamKiY6vZD/c4d1HnGIHMQXl7lm07wS2JSuR7CM7iNAw2PXWi rONw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=eUqxgP/s9xXB8XHemnXGPIAhH3INOml2gpGNRb4ehyI=; b=LdbeKnc+4CRvJsXuOR4IJORJUXh6D4NIiQVWLe4W8qaefrjnKGwYmKxAHRx5iO6Baz wN4KFx/ejGXJ9W+9RXfLH9stYc770n1UAnK26oDFqlsqsmtoe2OCotbcPT45lMk5+/O7 oODwYJ+e+qyXEc12w6j/Chcd/NM9DbYZfIXawvvda28OgyyzgbzYurTKdTIhi28QcMri Ovvaqow2Wb0QcUdkRmosnxOzAvNHvcIeyPbt9KVEudH8ugxIMHMDk8o2/ubyQJ6p06eV ZRcB1hf7LNarK95ecUyDijE4SV4uYvqCjvZbHARbZviSN/7KLDCj/KKulwdo6ILAR+TQ +6Xg== 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 b15si3742359edz.588.2020.06.30.19.22.48; Tue, 30 Jun 2020 19:23:11 -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 S1726621AbgGACWl (ORCPT + 99 others); Tue, 30 Jun 2020 22:22:41 -0400 Received: from mail.loongson.cn ([114.242.206.163]:49150 "EHLO loongson.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725988AbgGACWk (ORCPT ); Tue, 30 Jun 2020 22:22:40 -0400 Received: from linux.localdomain (unknown [113.200.148.30]) by mail.loongson.cn (Coremail) with SMTP id AQAAf9Dxz2r68fteU2dNAA--.5801S5; Wed, 01 Jul 2020 10:16:28 +0800 (CST) From: Tiezhu Yang To: Thomas Gleixner , Jason Cooper , Marc Zyngier Cc: linux-kernel@vger.kernel.org, Markus Elfring Subject: [PATCH v4 03/14] irqchip/csky-mpintc: Fix potential resource leaks Date: Wed, 1 Jul 2020 10:16:15 +0800 Message-Id: <1593569786-11500-4-git-send-email-yangtiezhu@loongson.cn> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1593569786-11500-1-git-send-email-yangtiezhu@loongson.cn> References: <1593569786-11500-1-git-send-email-yangtiezhu@loongson.cn> X-CM-TRANSID: AQAAf9Dxz2r68fteU2dNAA--.5801S5 X-Coremail-Antispam: 1UD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vcSsGvfC2KfnxnUUI43ZEXa7I UYn0eJUUUUU== X-CM-SenderInfo: p1dqw3xlh2x3gn0dqz5rrqw2lrqou0/ Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In the function csky_mpintc_init(), system resources "__trigger", "INTCG_base" and "root_domain" were not released in a few error cases. Thus add jump targets for the completion of the desired exception handling. By the way, do some coding-style cleanups suggested by Markus. Fixes: d8a5f5f79122 ("irqchip: add C-SKY SMP interrupt controller") Signed-off-by: Tiezhu Yang --- drivers/irqchip/irq-csky-mpintc.c | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/drivers/irqchip/irq-csky-mpintc.c b/drivers/irqchip/irq-csky-mpintc.c index a1534ed..d7edc28 100644 --- a/drivers/irqchip/irq-csky-mpintc.c +++ b/drivers/irqchip/irq-csky-mpintc.c @@ -241,14 +241,16 @@ csky_mpintc_init(struct device_node *node, struct device_node *parent) nr_irq = INTC_IRQS; __trigger = kcalloc(nr_irq, sizeof(unsigned long), GFP_KERNEL); - if (__trigger == NULL) + if (!__trigger) return -ENXIO; - if (INTCG_base == NULL) { + if (!INTCG_base) { INTCG_base = ioremap(mfcr("cr<31, 14>"), - INTCL_SIZE*nr_cpu_ids + INTCG_SIZE); - if (INTCG_base == NULL) - return -EIO; + INTCL_SIZE * nr_cpu_ids + INTCG_SIZE); + if (!INTCG_base) { + ret = -EIO; + goto err_free; + } INTCL_base = INTCG_base + INTCG_SIZE; @@ -257,8 +259,10 @@ csky_mpintc_init(struct device_node *node, struct device_node *parent) root_domain = irq_domain_add_linear(node, nr_irq, &csky_irqdomain_ops, NULL); - if (!root_domain) - return -ENXIO; + if (!root_domain) { + ret = -ENXIO; + goto err_iounmap; + } /* for every cpu */ for_each_present_cpu(cpu) { @@ -270,12 +274,24 @@ csky_mpintc_init(struct device_node *node, struct device_node *parent) #ifdef CONFIG_SMP ipi_irq = irq_create_mapping(root_domain, IPI_IRQ); - if (!ipi_irq) - return -EIO; + if (!ipi_irq) { + ret = -EIO; + goto err_domain_remove; + } set_send_ipi(&csky_mpintc_send_ipi, ipi_irq); #endif return 0; + +#ifdef CONFIG_SMP +err_domain_remove: + irq_domain_remove(root_domain); +#endif +err_iounmap: + iounmap(INTCG_base); +err_free: + kfree(__trigger); + return ret; } IRQCHIP_DECLARE(csky_mpintc, "csky,mpintc", csky_mpintc_init); -- 2.1.0