Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp226203ybt; Tue, 30 Jun 2020 19:17:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzldqx2yRmzMhIbLndaaXiILVgONzg1VD4+qPLRYop7BFRjPYoxU+lLtsAlnTfeD2s/vKhr X-Received: by 2002:a17:906:748:: with SMTP id z8mr21411223ejb.257.1593569870926; Tue, 30 Jun 2020 19:17:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593569870; cv=none; d=google.com; s=arc-20160816; b=OBaokJbktSE+QP9xTgcWvq05Jtf0s9hPoqK4ynDINsRHi5b8pReu5DHOCs68PNVGbn yib68vc5H+a9rKdFd7Udmww2iRAO2+UP+Xk9vsDDqczlFM0E6w467hbfhYlyZjhHKIoG EM5X+2sCSuXsGVk/2PRELJXFkmRzqI5pzsCLEjRF5MoE3BaYByjbz7tcKwOLrl2nTzZq TNEUG9NsppBAuOEE6CP9yyHAVnjpJSLM4YCULhk0VnXGStNWKqGNwthj01D/DfvsmgYM dFZLfL5qEfVkPVKc5HBRgvL80iGbbSvUxX96GltgGJbspiMpW7ffxRx906oEVYn/1kxa 3npg== 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=McLOyMWPSXKLQMKYeZu7GXDNbUkj3st/s2OgA1jy23c=; b=xWKZ9uggBTHX2z/FS2c2RbPGNtGOwm/nYuAXlqGhgr510suZ3aR5Q4fYU6xbpjW7kR K35x7mD1nD5xGYjfMnQs125mSveS/VrFFUF+qkAWiAjNkN1pXdDcL7tXUU/AEJYJIJgg 2VkeUkdrgmUYnLXjcFT00DDBWOZePIpfovI+oXiM0LvS8kkpdehxWIhfX9JwzFCuJe+L sy2tSZ8whWQ14UfSEpz/BTu9MnoHewRv/uCet+JKXNR8mXhGLabqYExNzKkwJ/9aZqCF q8j2MdeCuXR+dCbUHdngJwQplBUs6nT1rwLpFp0tilKtcluD+o4fAs8mNdJznX8G639L AAMg== 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 t2si2854358ejd.382.2020.06.30.19.17.27; Tue, 30 Jun 2020 19:17:50 -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 S1726921AbgGACQz (ORCPT + 99 others); Tue, 30 Jun 2020 22:16:55 -0400 Received: from mail.loongson.cn ([114.242.206.163]:47690 "EHLO loongson.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726754AbgGACQh (ORCPT ); Tue, 30 Jun 2020 22:16:37 -0400 Received: from linux.localdomain (unknown [113.200.148.30]) by mail.loongson.cn (Coremail) with SMTP id AQAAf9Dxz2r68fteU2dNAA--.5801S6; 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 04/14] irqchip/davinci-aintc: Fix potential resource leaks Date: Wed, 1 Jul 2020 10:16:16 +0800 Message-Id: <1593569786-11500-5-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--.5801S6 X-Coremail-Antispam: 1UD129KBjv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0DKItUUUUU== 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 davinci_aintc_init(), system resources "config->reg.start", "davinci_aintc_base", "irq_base" and "davinci_aintc_irq_domain" were not released in a few error cases. Thus add jump targets for the completion of the desired exception handling. Fixes: 0145beed9d26 ("irqchip: davinci-aintc: move the driver to drivers/irqchip") Signed-off-by: Tiezhu Yang --- drivers/irqchip/irq-davinci-aintc.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/drivers/irqchip/irq-davinci-aintc.c b/drivers/irqchip/irq-davinci-aintc.c index 810ccc4..2a96dc9 100644 --- a/drivers/irqchip/irq-davinci-aintc.c +++ b/drivers/irqchip/irq-davinci-aintc.c @@ -96,7 +96,7 @@ void __init davinci_aintc_init(const struct davinci_aintc_config *config) resource_size(&config->reg)); if (!davinci_aintc_base) { pr_err("%s: unable to ioremap register range\n", __func__); - return; + goto err_release; } /* Clear all interrupt requests */ @@ -133,7 +133,7 @@ void __init davinci_aintc_init(const struct davinci_aintc_config *config) if (irq_base < 0) { pr_err("%s: unable to allocate interrupt descriptors: %d\n", __func__, irq_base); - return; + goto err_iounmap; } davinci_aintc_irq_domain = irq_domain_add_legacy(NULL, @@ -141,7 +141,7 @@ void __init davinci_aintc_init(const struct davinci_aintc_config *config) &irq_domain_simple_ops, NULL); if (!davinci_aintc_irq_domain) { pr_err("%s: unable to create interrupt domain\n", __func__); - return; + goto err_free_descs; } ret = irq_alloc_domain_generic_chips(davinci_aintc_irq_domain, 32, 1, @@ -150,7 +150,7 @@ void __init davinci_aintc_init(const struct davinci_aintc_config *config) if (ret) { pr_err("%s: unable to allocate generic irq chips for domain\n", __func__); - return; + goto err_domain_remove; } for (irq_off = 0, reg_off = 0; @@ -160,4 +160,14 @@ void __init davinci_aintc_init(const struct davinci_aintc_config *config) irq_base + irq_off, 32); set_handle_irq(davinci_aintc_handle_irq); + return; + +err_domain_remove: + irq_domain_remove(davinci_aintc_irq_domain); +err_free_descs: + irq_free_descs(irq_base, config->num_irqs); +err_iounmap: + iounmap(davinci_aintc_base); +err_release: + release_mem_region(config->reg.start, resource_size(&config->reg)); } -- 2.1.0