Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BD125C4167B for ; Mon, 6 Nov 2023 23:17:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Y9SbgJNik2eyX9e4v9yK2Cy0czpxrpameKvEDqX3UAw=; b=3VlKpoYLEGvNX8 FIuRldMEAjRib1Ua0f0tI6sK1ZtEZZ2TiWpptZ9XopMGpa4gOLQdqhV2p0U0u+GCQW3rgDZJJ8cdD M94+v8lgfRIjsoaINeGB/zXDZG/9qhrGOAiqz6c5r5hPcX/dVQ1Rwwbh4G+Im89cBAzDTZbiUVT/v gngUmsailDwud1IrPBe6yZ0gLk1TFvNyylkUn+j+GTMvYmbMrHxyoakM2SzfPtfJNnTFnEyaWtxvU qEGwDR4Op8KT2aWMtq5br6XRTFqA4+IO1Ufpq6FVftBJ5yXlvOA7y4TybBSYB9eRKuJRKxoWGETYl mbtWdt7LqCLhU06OU82Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r08ps-0007ys-1U; Mon, 06 Nov 2023 23:16:48 +0000 Received: from ams.source.kernel.org ([145.40.68.75]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r08pp-0007x4-1k for linux-arm-kernel@lists.infradead.org; Mon, 06 Nov 2023 23:16:47 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by ams.source.kernel.org (Postfix) with ESMTP id 2BC8AB8121A; Mon, 6 Nov 2023 23:16:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E4365C433C8; Mon, 6 Nov 2023 23:16:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1699312603; bh=0arbaNvnIAxlUW81YmPdpGIiJDwasLYkkL9kpZGsC8g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ts2Z4Lu+PSkLgcRLcZFqoBNk/DOMyf4olS2F9P4VzT+ltKwePuxS7WxF2+bNXYoOh vRF0UXKNpa1NXumeI4FMB4Qs7bUKJUL/p48Od9zo0U5an0Ko4EX9oF/7l7gy73UBu7 HN3/RYOxoDm3goPTW4Mt9YXjDV4blQXNERhQ2CgCnUp91rF6Z5OjL87NS4s8IXykgB ASRH+t21ZFSXCMOnvxGnhf0voSGvMi82hO3lZ6hc/bFHF4RoLpfzGIZNw0YzhfcY5l C3PCbcdPLc59RRuPSMPfx9F7kZqORqqA9BmmJRTqlYb9qdqM56dYhwB7eAqx6/6NkD ehKb+cvrOrjEw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Jacky Bai , Peng Fan , Daniel Lezcano , Sasha Levin , tglx@linutronix.de, shawnguo@kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH AUTOSEL 5.10 2/5] clocksource/drivers/timer-imx-gpt: Fix potential memory leak Date: Mon, 6 Nov 2023 18:16:33 -0500 Message-ID: <20231106231639.3735753-2-sashal@kernel.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231106231639.3735753-1-sashal@kernel.org> References: <20231106231639.3735753-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 5.10.199 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231106_151645_728013_6DDECD67 X-CRM114-Status: GOOD ( 11.82 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Jacky Bai [ Upstream commit 8051a993ce222a5158bccc6ac22ace9253dd71cb ] Fix coverity Issue CID 250382: Resource leak (RESOURCE_LEAK). Add kfree when error return. Signed-off-by: Jacky Bai Reviewed-by: Peng Fan Signed-off-by: Daniel Lezcano Link: https://lore.kernel.org/r/20231009083922.1942971-1-ping.bai@nxp.com Signed-off-by: Sasha Levin --- drivers/clocksource/timer-imx-gpt.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/drivers/clocksource/timer-imx-gpt.c b/drivers/clocksource/timer-imx-gpt.c index 7b2c70f2f353b..fabff69e52e58 100644 --- a/drivers/clocksource/timer-imx-gpt.c +++ b/drivers/clocksource/timer-imx-gpt.c @@ -454,12 +454,16 @@ static int __init mxc_timer_init_dt(struct device_node *np, enum imx_gpt_type t return -ENOMEM; imxtm->base = of_iomap(np, 0); - if (!imxtm->base) - return -ENXIO; + if (!imxtm->base) { + ret = -ENXIO; + goto err_kfree; + } imxtm->irq = irq_of_parse_and_map(np, 0); - if (imxtm->irq <= 0) - return -EINVAL; + if (imxtm->irq <= 0) { + ret = -EINVAL; + goto err_kfree; + } imxtm->clk_ipg = of_clk_get_by_name(np, "ipg"); @@ -472,11 +476,15 @@ static int __init mxc_timer_init_dt(struct device_node *np, enum imx_gpt_type t ret = _mxc_timer_init(imxtm); if (ret) - return ret; + goto err_kfree; initialized = 1; return 0; + +err_kfree: + kfree(imxtm); + return ret; } static int __init imx1_timer_init_dt(struct device_node *np) -- 2.42.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel