Skip to content

Commit 21c0efb

Browse files
visitorckwabelvesa
authored andcommitted
clk: imx: scu: Fix memory leak in __imx_clk_gpr_scu()
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@gmail.com> Reviewed-by: Peng Fan <peng.fan@nxp.com> Link: https://lore.kernel.org/all/20231210171907.3410922-1-visitorckw@gmail.com/ Signed-off-by: Abel Vesa <abel.vesa@linaro.org>
1 parent 144f1b7 commit 21c0efb

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

drivers/clk/imx/clk-scu.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -886,8 +886,10 @@ struct clk_hw *__imx_clk_gpr_scu(const char *name, const char * const *parent_na
886886
return ERR_PTR(-EINVAL);
887887
}
888888

889-
if (!imx_clk_is_resource_owned(rsrc_id))
889+
if (!imx_clk_is_resource_owned(rsrc_id)) {
890+
kfree(clk_node);
890891
return NULL;
892+
}
891893

892894
clk = kzalloc(sizeof(*clk), GFP_KERNEL);
893895
if (!clk) {

0 commit comments

Comments
 (0)