[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240122145608.990137-70-sashal@kernel.org>
Date: Mon, 22 Jan 2024 09:51:43 -0500
From: Sasha Levin <sashal@...nel.org>
To: linux-kernel@...r.kernel.org,
stable@...r.kernel.org
Cc: Kuan-Wei Chiu <visitorckw@...il.com>,
Peng Fan <peng.fan@....com>,
Abel Vesa <abel.vesa@...aro.org>,
Sasha Levin <sashal@...nel.org>,
abelvesa@...nel.org,
mturquette@...libre.com,
sboyd@...nel.org,
shawnguo@...nel.org,
linux-clk@...r.kernel.org,
linux-imx@....com,
linux-arm-kernel@...ts.infradead.org
Subject: [PATCH AUTOSEL 6.7 70/88] clk: imx: scu: Fix memory leak in __imx_clk_gpr_scu()
From: Kuan-Wei Chiu <visitorckw@...il.com>
[ 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 <visitorckw@...il.com>
Reviewed-by: Peng Fan <peng.fan@....com>
Link: https://lore.kernel.org/all/20231210171907.3410922-1-visitorckw@gmail.com/
Signed-off-by: Abel Vesa <abel.vesa@...aro.org>
Signed-off-by: Sasha Levin <sashal@...nel.org>
---
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
Powered by blists - more mailing lists