clk: imx: scu: fix a potential memory leak in __imx_clk_gpr_scu()
authorXiaoke Wang <xkernel.wang@foxmail.com>
Thu, 7 Apr 2022 07:37:22 +0000 (15:37 +0800)
committerAbel Vesa <abel.vesa@nxp.com>
Tue, 12 Apr 2022 11:02:02 +0000 (14:02 +0300)
commit2759f38b6c9551e4a1184131bc660d6a520a7cf4
tree73d9c9d1323dfd4f8b2622e7796761dfdd1dd2bd
parented713e2bc093239ccd380c2ce8ae9e4162f5c037
clk: imx: scu: fix a potential memory leak in __imx_clk_gpr_scu()

In __imx_clk_gpr_scu(), if imx_scu_clk_is_valid(rsrc_id) fails, then
`clk_node` which is allocated by kzalloc() is not properly released,
which may lead to memory leak.
So this patch added kfree(clk_node) on the above error path before
return ERR_PTR(-EINVAL).

Signed-off-by: Xiaoke Wang <xkernel.wang@foxmail.com>
Reviewed-by: Abel Vesa <abel.vesa@nxp.com>
Link: https://lore.kernel.org/r/tencent_27FF59903EE6AB5C0D0E6D0A8E7059A59007@qq.com
Signed-off-by: Abel Vesa <abel.vesa@nxp.com>
drivers/clk/imx/clk-scu.c