Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp229400ybt; Tue, 30 Jun 2020 19:24:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyxw3PjpDKCGvEcPbcvD5Io8l8u24AwhthTytrR+7wZNjZjQpabXbJjnSRkD0aSPgs6EtqU X-Received: by 2002:a17:906:7802:: with SMTP id u2mr21500192ejm.478.1593570267099; Tue, 30 Jun 2020 19:24:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593570267; cv=none; d=google.com; s=arc-20160816; b=X2thLFJEUOWq1ufQ83oTJ12XFT/dBYQfPeINjjleTLo8Ft2qy+gzcf0EFsTtAIgBMn 478rNHbVmrF5mAhHKp8ROPflqDvAeWC4NluNKpBiA//+XXUfWgcyJewMshhDcCW/EcJC rPRI+qn68cSwVK/UBTkU9Z2mSMpiQYf+RMrO+YaqAwl+/Egiy+uzHMnXCxeR7vfthOUv dEsSYs7aAjZSsbXBKuVgizscBPgXEW1SQDND8YIwqrUEuv3qG6uojZGkaz+AAnZzibcD x77pkH76KqmRQ3tiCL1gcXOSZ3hkMa4ETMsuDwJAlWJQe5y/x+1GxTEKNKx+MAW4H13h DlSw== 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=asfeQNd8IuAArR35Y7lg320YJgw4bPdxPA3MPommv1Y=; b=H6jawduk6cV3IbA+zf/oR+v8oU6WXwxodKYXPAIaNrXjwgORrvz/5CCR1h9jGttuQQ gr6TXNdNPDI7SaYVQOA7ItdtJyhQ0zs4JP88IKyBVOkRseWPUOEa3h8zSqVbRa0T97qh CDUrdjg0Hde/a3a+QOBdun5917oXE4kcrmJYpdCEgdfATSkFBIpYPix0O93QcZWnUvfE TCrqbv0G69hRubLw2jCfvyy67uwAFw4TfQpeVceG1bYtkVXVhSq9KbjyUaYuUll8+A50 cIJivdKd5hnKhLI2e+iZ0pvarKpGOHbLJ5UpMQppX2YUgqwH+WKy0xRlDjrxE1fN2dnP Q13w== 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 dr21si3898971ejc.489.2020.06.30.19.24.03; Tue, 30 Jun 2020 19:24:27 -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 S1726208AbgGACWk (ORCPT + 99 others); Tue, 30 Jun 2020 22:22:40 -0400 Received: from mail.loongson.cn ([114.242.206.163]:49148 "EHLO loongson.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726053AbgGACWk (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--.5801S15; Wed, 01 Jul 2020 10:16:31 +0800 (CST) From: Tiezhu Yang To: Thomas Gleixner , Jason Cooper , Marc Zyngier Cc: linux-kernel@vger.kernel.org, Markus Elfring Subject: [PATCH v4 13/14] irqchip/s3c24xx: Fix potential resource leaks Date: Wed, 1 Jul 2020 10:16:25 +0800 Message-Id: <1593569786-11500-14-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--.5801S15 X-Coremail-Antispam: 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jDU0xZFpf9x07jr6p9UUUUU= 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 s3c_init_intc_of(), system resource "reg_base", "domain" and "intc" were not released in a few error cases. Thus add jump targets for the completion of the desired exception handling. Fixes: f0774d41da0e ("irqchip: s3c24xx: add devicetree support") Signed-off-by: Tiezhu Yang --- drivers/irqchip/irq-s3c24xx.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/drivers/irqchip/irq-s3c24xx.c b/drivers/irqchip/irq-s3c24xx.c index d2031fe..166c27b 100644 --- a/drivers/irqchip/irq-s3c24xx.c +++ b/drivers/irqchip/irq-s3c24xx.c @@ -1227,7 +1227,7 @@ static int __init s3c_init_intc_of(struct device_node *np, struct s3c24xx_irq_of_ctrl *ctrl; struct irq_domain *domain; void __iomem *reg_base; - int i; + int i, ret; reg_base = of_iomap(np, 0); if (!reg_base) { @@ -1239,7 +1239,8 @@ static int __init s3c_init_intc_of(struct device_node *np, &s3c24xx_irq_ops_of, NULL); if (!domain) { pr_err("irq: could not create irq-domain\n"); - return -EINVAL; + ret = -EINVAL; + goto out_iounmap; } for (i = 0; i < num_ctrl; i++) { @@ -1248,15 +1249,17 @@ static int __init s3c_init_intc_of(struct device_node *np, pr_debug("irq: found controller %s\n", ctrl->name); intc = kzalloc(sizeof(struct s3c_irq_intc), GFP_KERNEL); - if (!intc) - return -ENOMEM; + if (!intc) { + ret = -ENOMEM; + goto out_domain_remove; + } intc->domain = domain; intc->irqs = kcalloc(32, sizeof(struct s3c_irq_data), GFP_KERNEL); if (!intc->irqs) { - kfree(intc); - return -ENOMEM; + ret = -ENOMEM; + goto out_free; } if (ctrl->parent) { @@ -1285,6 +1288,14 @@ static int __init s3c_init_intc_of(struct device_node *np, set_handle_irq(s3c24xx_handle_irq); return 0; + +out_free: + kfree(intc); +out_domain_remove: + irq_domain_remove(domain); +out_iounmap: + iounmap(reg_base); + return ret; } static struct s3c24xx_irq_of_ctrl s3c2410_ctrl[] = { -- 2.1.0