]> git.baikalelectronics.ru Git - kernel.git/commitdiff
clk: rockchip: Fix memory leak in rockchip_clk_register_pll()
authorXiu Jianfeng <xiujianfeng@huawei.com>
Wed, 23 Nov 2022 09:12:01 +0000 (17:12 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 18 Jan 2023 10:41:05 +0000 (11:41 +0100)
[ Upstream commit 739a6a6bbdb793bd57938cb24aa5a6df89983546 ]

If clk_register() fails, @pll->rate_table may have allocated memory by
kmemdup(), so it needs to be freed, otherwise will cause memory leak
issue, this patch fixes it.

Fixes: e636325c3f13 ("clk: rockchip: add clock type for pll clocks and pll used on rk3066")
Signed-off-by: Xiu Jianfeng <xiujianfeng@huawei.com>
Link: https://lore.kernel.org/r/20221123091201.199819-1-xiujianfeng@huawei.com
Signed-off-by: Heiko Stuebner <heiko@sntech.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/clk/rockchip/clk-pll.c

index 198417d5630062eeaa220f1f8ed3df3eb17c29a1..aa8a299ff704a86c006e22302a4add23bf6bda64 100644 (file)
@@ -963,6 +963,7 @@ struct clk *rockchip_clk_register_pll(struct rockchip_clk_provider *ctx,
        return mux_clk;
 
 err_pll:
+       kfree(pll->rate_table);
        clk_unregister(mux_clk);
        mux_clk = pll_clk;
 err_mux: