Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp227421ybt; Tue, 30 Jun 2020 19:20:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzyDbdmqyncqm2bhgou/hRgF08PEVF/hlyzTkyW0A3oEIEdsHqBifbgJWv3xPxmDx3/gc4Q X-Received: by 2002:a17:906:edbb:: with SMTP id sa27mr22034217ejb.438.1593570024282; Tue, 30 Jun 2020 19:20:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593570024; cv=none; d=google.com; s=arc-20160816; b=u3gtocYPUFE+s0Z4xDlsLhAFjWgQLzJuTvcsoRPmd7RgeJkEafdxy04mn003D0ftdt 1YA76erRetdbcaLonHIJ26T3JW2uJYhyjRuIxRJS9uR+Ew9sBPbWgPIJnCjvgzzq/T98 bnN2tvNDFOqKgK+LiQVm8/0LYlpLwb9r2EhYBdzCe5PEXL46Z0G/C1+gOtKZiQJEXcjr XhEgWpah8ed/u6Tgbwuq563nhDcjVyjx/5X5ok5YYauJcYoow5SAyYuiZ2Tg+v+ebaCi H09jwAvEDtiQvlyDscP7nzWXPE3AuTWd005e6USUEYMDu8ChiWrIR16AyT+UrQ/N5aZt jfJg== 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=b4qrcjtbnS6Wh2t5vaDD+iJ929pgUswxdJxrfYA9OGU=; b=M3SuvAHbzisCu+5sJxLjd/KN8Ynb+Ba8UV34JlYSTq1MLJgH6gs1ARVAcSE08/bA5T B82zXS1cL9NKLqN2pOv/lIs4QGRY/mbriUam1/18pWk+9wooVfi9BbLRyuVq+69EoafI nUkGR72xxVbRkAHjjlUSLyzrOnE0RFOdB4Sz4Cbf4/YE9nhL7cUq/7O4+K1Dd1n7qErr NW5EBcVlIt7/C6hPji/37VWkSz3jRrG3RPY893qjDSfK6WF3E0xmNlmjaK/bhviSBSZD pR14f3caRIqvWaWAuR/T6vYU7YOmZpCOEb8TNbUrfk71/cFGyovrWv1MNzIcGwjNNLTF E5+Q== 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 m20si2970118eds.126.2020.06.30.19.20.01; Tue, 30 Jun 2020 19:20:24 -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 S1726987AbgGACRN (ORCPT + 99 others); Tue, 30 Jun 2020 22:17:13 -0400 Received: from mail.loongson.cn ([114.242.206.163]:47694 "EHLO loongson.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726726AbgGACQg (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--.5801S9; Wed, 01 Jul 2020 10:16:29 +0800 (CST) From: Tiezhu Yang To: Thomas Gleixner , Jason Cooper , Marc Zyngier Cc: linux-kernel@vger.kernel.org, Markus Elfring Subject: [PATCH v4 07/14] irqchip/dw-apb-ictl: Fix potential resource leaks Date: Wed, 1 Jul 2020 10:16:19 +0800 Message-Id: <1593569786-11500-8-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--.5801S9 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IYCTnIWIevJa73UjIFyTuYvjxU4eMKDUUUU 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 dw_apb_ictl_init(), system resources "irq" and "domain" were not released in a few error cases. Thus add jump targets for the completion of the desired exception handling. Fixes: 350d71b94fc9 ("irqchip: add DesignWare APB ICTL interrupt controller") Signed-off-by: Tiezhu Yang --- drivers/irqchip/irq-dw-apb-ictl.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/irqchip/irq-dw-apb-ictl.c b/drivers/irqchip/irq-dw-apb-ictl.c index e4550e9..bc9b750 100644 --- a/drivers/irqchip/irq-dw-apb-ictl.c +++ b/drivers/irqchip/irq-dw-apb-ictl.c @@ -86,12 +86,13 @@ static int __init dw_apb_ictl_init(struct device_node *np, ret = of_address_to_resource(np, 0, &r); if (ret) { pr_err("%pOF: unable to get resource\n", np); - return ret; + goto err_irq_dispose; } if (!request_mem_region(r.start, resource_size(&r), np->full_name)) { pr_err("%pOF: unable to request mem region\n", np); - return -ENOMEM; + ret = -ENOMEM; + goto err_irq_dispose; } iobase = ioremap(r.start, resource_size(&r)); @@ -133,7 +134,7 @@ static int __init dw_apb_ictl_init(struct device_node *np, IRQ_GC_INIT_MASK_CACHE); if (ret) { pr_err("%pOF: unable to alloc irq domain gc\n", np); - goto err_unmap; + goto err_domain_remove; } for (i = 0; i < DIV_ROUND_UP(nrirqs, 32); i++) { @@ -150,10 +151,14 @@ static int __init dw_apb_ictl_init(struct device_node *np, return 0; +err_domain_remove: + irq_domain_remove(domain); err_unmap: iounmap(iobase); err_release: release_mem_region(r.start, resource_size(&r)); +err_irq_dispose: + irq_dispose_mapping(irq); return ret; } IRQCHIP_DECLARE(dw_apb_ictl, -- 2.1.0