From mboxrd@z Thu Jan 1 00:00:00 1970 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 6B78CC47E49 for ; Mon, 22 Jan 2024 15:01:43 +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=70f2sISvqfKh5iqELRcBcrzt76rM9A66art9PAFiYsg=; b=l50caUZcYkruex 2y/OdU6PBUYHVXNTZDegkYpU0xKurpqGp0OcanF5Ma6XlcTBLYPuW7bOr2Z3qNGyrPlbDH8oQGLq6 TvuvsGyGCW7VdjDimbAKpOQCDEhNjm/MbKSikMDA00pguRpBnzfEitVybjZBYD9EQmnnriAamUf3Y H9rkrOQwyUNnCCaffiE8+ZGjY15EvDgAuMV+rbS2jTUo6vO9pug1XKGEesfbZZYVGwB5n20Ty8sdI qrsy1w4TanXyIcg39+uHE52ZKl9wzCVez5aSlogTBIAzzZrs/O7EBdSCjiAF9ndILJpq5n9T0QZjD q0FeFZUsOvlTfDeuawsw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rRvnW-00CYHB-1F; Mon, 22 Jan 2024 15:01:14 +0000 Received: from ams.source.kernel.org ([2604:1380:4601:e00::1]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rRvnS-00CYFf-17 for linux-arm-kernel@lists.infradead.org; Mon, 22 Jan 2024 15:01:11 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by ams.source.kernel.org (Postfix) with ESMTP id 179FAB80E7D; Mon, 22 Jan 2024 15:01:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0249FC43394; Mon, 22 Jan 2024 15:01:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705935668; bh=5WiHhm/3Z4FSDuRuN9E/aZI8EX2lzNesoBNgmQECzkc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NgzukqFbTvU0/Rnl/513hRPQfkemXcibPiFWGDrVCVi2HU0BYWnDah0vRlC/eCwc3 GehH4RxayyJRSPmqShH65rDkFNYR5F7IvEOM9GcasEkEGEAogbK365KzuvmxTdOcda /SZkBNVGqDu33DKr44AgZZTx7ioo07Ww6vKBA4ug3HDptNL8DruymlknX9eRS0L0Et qYeSLGEl/N1ULxdOSZh6dGkIUGLWYmeBg7JNvmAGfDHaAMYxPK42PQeDuI9I5vyVQO xhOyRPyj/OPrZ8hz/x2j1B0o4jQtN9bjFf8+h7WTNSLyl66Fd3wwZBGoSpp0DMKwSm sJx+qb/FpcTpQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Kuan-Wei Chiu , Peng Fan , Abel Vesa , Sasha Levin , abelvesa@kernel.org, mturquette@baylibre.com, sboyd@kernel.org, shawnguo@kernel.org, linux-clk@vger.kernel.org, linux-imx@nxp.com, linux-arm-kernel@lists.infradead.org Subject: [PATCH AUTOSEL 6.7 70/88] clk: imx: scu: Fix memory leak in __imx_clk_gpr_scu() Date: Mon, 22 Jan 2024 09:51:43 -0500 Message-ID: <20240122145608.990137-70-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240122145608.990137-1-sashal@kernel.org> References: <20240122145608.990137-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.7.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240122_070110_516941_44FC83A7 X-CRM114-Status: GOOD ( 11.35 ) 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: Kuan-Wei Chiu [ Upstream commit 21c0efbcb45cf94724d17b040ebc03fcd4a81f22 ] In cases where imx_clk_is_resource_owned() returns false, the code path does not handle the failure gracefully, potentially leading to a memory leak. This fix ensures proper cleanup by freeing the allocated memory for 'clk_node' before returning. Signed-off-by: Kuan-Wei Chiu Reviewed-by: Peng Fan Link: https://lore.kernel.org/all/20231210171907.3410922-1-visitorckw@gmail.com/ Signed-off-by: Abel Vesa Signed-off-by: Sasha Levin --- drivers/clk/imx/clk-scu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/clk/imx/clk-scu.c b/drivers/clk/imx/clk-scu.c index be89180dd19c..e48a904c0013 100644 --- a/drivers/clk/imx/clk-scu.c +++ b/drivers/clk/imx/clk-scu.c @@ -886,8 +886,10 @@ struct clk_hw *__imx_clk_gpr_scu(const char *name, const char * const *parent_na return ERR_PTR(-EINVAL); } - if (!imx_clk_is_resource_owned(rsrc_id)) + if (!imx_clk_is_resource_owned(rsrc_id)) { + kfree(clk_node); return NULL; + } clk = kzalloc(sizeof(*clk), GFP_KERNEL); if (!clk) { -- 2.43.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel