Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp226525ybt; Tue, 30 Jun 2020 19:18:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzeb1RFr3v+mWjpJgaraH5iyodAk3oFH/sEMmV9Wh33nh2wVCOS+i+twVy/0ExJkIfpcXl6 X-Received: by 2002:a17:906:4a45:: with SMTP id a5mr20314138ejv.384.1593569914275; Tue, 30 Jun 2020 19:18:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593569914; cv=none; d=google.com; s=arc-20160816; b=LGHSXfJmf0ip6MoOXI0QQbP1W2PzQTkXEasn1p25Dz+8FizY/DI/5dN3PG5497UoN7 uJiv1LYP1D2xpfSOAaiRDKsm9GildJ7CJe8WgZgXfnR6vBApIxPtkso7SQDu/a+k4mUp nRFXOFlcFaVeC4eYR0FBfMOYFglnoYo2flocDQW20MAYMrHb6FQSOdwdYjZbOWSaiREs MHHsvp45bUzHS43SN5MLbQT477tUJ/jVdORirj/Vv747OtW2qV8RBqqGhzK3bnai1AuS ZcM5YZjl8jklz6n564uGIuKYW8wv3hhZFVzLfcVLQ7wUPyNBPMg/Uwkr2r9m1kLnzTfY K+fg== 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=RXDfCDw+AqbHHaSSSF1zOEi/PTwiLpslMCk4xWhy2Q4=; b=CXt04iTKk4FXqhjeZgo6wGBDf9myoRWdGeCaKBPDKb+47eX0A8kb6FOicSws24IH9q h+vesEYJf4MeDmeTTBK++eGATCUuvOaadFSyCp2EwhstUDHMjtU/nnn6SQbPmd7PvrDT Sa60XrpOTv4G4vTw232y/wHd/BRVvEx3zQSDUMB3LfWP5AqHrN9dop8IbsX89eBJvjw0 6ErpE8KqiHK+XTNUYMvzxHec2jTe8gJhKaOGmW28sNSpWhevVquLIQ7YWC4R+1j4q6bO HxK9ovLYjnr8jr9pEHE84h7FCzCYME36knTjk+ugjHXGiPkfySZFPX6MiGZ0llkDlRil Uw1A== 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 ef2si3046998ejb.636.2020.06.30.19.18.11; Tue, 30 Jun 2020 19:18:34 -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 S1727000AbgGACRQ (ORCPT + 99 others); Tue, 30 Jun 2020 22:17:16 -0400 Received: from mail.loongson.cn ([114.242.206.163]:47672 "EHLO loongson.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726724AbgGACQg (ORCPT ); Tue, 30 Jun 2020 22:16:36 -0400 Received: from linux.localdomain (unknown [113.200.148.30]) by mail.loongson.cn (Coremail) with SMTP id AQAAf9Dxz2r68fteU2dNAA--.5801S7; 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 05/14] irqchip/davinci-cp-intc: Fix potential resource leaks Date: Wed, 1 Jul 2020 10:16:17 +0800 Message-Id: <1593569786-11500-6-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--.5801S7 X-Coremail-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fC2KfnxnUUI43ZEXa7IU8Gii3UUUUU== 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_cp_intc_do_init(), system resources "config->reg.start", "davinci_cp_intc_base" and "irq_base" were not released in a few error cases. Thus add jump targets for the completion of the desired exception handling. Fixes: 0fc3d74cf946 ("irqchip: davinci-cp-intc: move the driver to drivers/irqchip") Signed-off-by: Tiezhu Yang --- drivers/irqchip/irq-davinci-cp-intc.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/drivers/irqchip/irq-davinci-cp-intc.c b/drivers/irqchip/irq-davinci-cp-intc.c index 276da277..2c2e115 100644 --- a/drivers/irqchip/irq-davinci-cp-intc.c +++ b/drivers/irqchip/irq-davinci-cp-intc.c @@ -162,6 +162,7 @@ davinci_cp_intc_do_init(const struct davinci_cp_intc_config *config, unsigned int num_regs = BITS_TO_LONGS(config->num_irqs); int offset, irq_base; void __iomem *req; + int ret; req = request_mem_region(config->reg.start, resource_size(&config->reg), @@ -175,7 +176,8 @@ davinci_cp_intc_do_init(const struct davinci_cp_intc_config *config, resource_size(&config->reg)); if (!davinci_cp_intc_base) { pr_err("%s: unable to ioremap register range\n", __func__); - return -EINVAL; + ret = -EINVAL; + goto err_release; } davinci_cp_intc_write(0, DAVINCI_CP_INTC_GLOBAL_ENABLE); @@ -210,7 +212,8 @@ davinci_cp_intc_do_init(const struct davinci_cp_intc_config *config, if (irq_base < 0) { pr_err("%s: unable to allocate interrupt descriptors: %d\n", __func__, irq_base); - return irq_base; + ret = irq_base; + goto err_iounmap; } davinci_cp_intc_irq_domain = irq_domain_add_legacy( @@ -219,7 +222,8 @@ davinci_cp_intc_do_init(const struct davinci_cp_intc_config *config, if (!davinci_cp_intc_irq_domain) { pr_err("%s: unable to create an interrupt domain\n", __func__); - return -EINVAL; + ret = -EINVAL; + goto err_free_descs; } set_handle_irq(davinci_cp_intc_handle_irq); @@ -228,6 +232,14 @@ davinci_cp_intc_do_init(const struct davinci_cp_intc_config *config, davinci_cp_intc_write(1, DAVINCI_CP_INTC_GLOBAL_ENABLE); return 0; + +err_free_descs: + irq_free_descs(irq_base, config->num_irqs); +err_iounmap: + iounmap(davinci_cp_intc_base); +err_release: + release_mem_region(config->reg.start, resource_size(&config->reg)); + return ret; } int __init davinci_cp_intc_init(const struct davinci_cp_intc_config *config) -- 2.1.0