Re: [PATCH] clk: imx93: fix memory leak and missing unwind goto in imx93_clocks_probe

From: Peng Fan
Date: Fri Apr 28 2023 - 03:51:41 EST




On 4/26/2023 10:25 PM, Zhanhao Hu wrote:
In function probe(), it returns directly without unregistered hws
when error occurs.

I fix this by adding 'goto unregister_hws;' on line 295 and
line 310.

Besides, I use devm_kzalloc() instead of kzalloc() to automatically
free the memory using devm_kfree() when error occurs.

Similarly, I replace of_iomap() with devm_of_iomap() to automatically
handle the unused ioremap region. So I delete 'iounmap(anatop_base);'
in unregister_hws.

Fixes: 24defbe194b6 ("clk: imx: add i.MX93 clk")
Signed-off-by: Zhanhao Hu<zero12113@xxxxxxxxxxx>
Reviewed-by: Dongliang Mu<dzm91@xxxxxxxxxxx>

Actually the clk driver should never fail, otherwise the system will not boot. But anyway it is fine to include the changes:

Reviewed-by: Peng Fan <peng.fan@xxxxxxx>