Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

clk: st: Fix memory leak in st_of_quadfs_setup()

If st_clk_register_quadfs_pll() fails, @lock should be freed before goto
@err_exit, otherwise will cause meory leak issue, fix it.

Signed-off-by: Xiu Jianfeng <xiujianfeng@huawei.com>
Link: https://lore.kernel.org/r/20221122133614.184910-1-xiujianfeng@huawei.com
Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>
Signed-off-by: Stephen Boyd <sboyd@kernel.org>

authored by

Xiu Jianfeng and committed by
Stephen Boyd
cfd3ffb3 5174e5b0

+3 -2
+3 -2
drivers/clk/st/clkgen-fsyn.c
··· 1020 1020 1021 1021 clk = st_clk_register_quadfs_pll(pll_name, clk_parent_name, datac->data, 1022 1022 reg, lock); 1023 - if (IS_ERR(clk)) 1023 + if (IS_ERR(clk)) { 1024 + kfree(lock); 1024 1025 goto err_exit; 1025 - else 1026 + } else 1026 1027 pr_debug("%s: parent %s rate %u\n", 1027 1028 __clk_get_name(clk), 1028 1029 __clk_get_name(clk_get_parent(clk)),