mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-05 10:31:46 +09:00
clk: imx93: fix memory leak and missing unwind goto in imx93_clocks_probe
[ Upstream commite02ba11b45] In function probe(), it returns directly without unregistered hws when error occurs. Fix this by adding 'goto unregister_hws;' on line 295 and line 310. Use devm_kzalloc() instead of kzalloc() to automatically free the memory using devm_kfree() when error occurs. Replace of_iomap() with devm_of_iomap() to automatically handle the unused ioremap region and delete 'iounmap(anatop_base);' in unregister_hws. Fixes:24defbe194("clk: imx: add i.MX93 clk") Signed-off-by: Zhanhao Hu <zero12113@hust.edu.cn> Reviewed-by: Abel Vesa <abel.vesa@linaro.org> Link: https://lore.kernel.org/r/20230601033825.336558-1-zero12113@hust.edu.cn Signed-off-by: Abel Vesa <abel.vesa@linaro.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
9ba3693b03
commit
280a5ff665
@@ -261,7 +261,7 @@ static int imx93_clocks_probe(struct platform_device *pdev)
|
|||||||
void __iomem *base, *anatop_base;
|
void __iomem *base, *anatop_base;
|
||||||
int i, ret;
|
int i, ret;
|
||||||
|
|
||||||
clk_hw_data = kzalloc(struct_size(clk_hw_data, hws,
|
clk_hw_data = devm_kzalloc(dev, struct_size(clk_hw_data, hws,
|
||||||
IMX93_CLK_END), GFP_KERNEL);
|
IMX93_CLK_END), GFP_KERNEL);
|
||||||
if (!clk_hw_data)
|
if (!clk_hw_data)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
@@ -285,10 +285,12 @@ static int imx93_clocks_probe(struct platform_device *pdev)
|
|||||||
"sys_pll_pfd2", 1, 2);
|
"sys_pll_pfd2", 1, 2);
|
||||||
|
|
||||||
np = of_find_compatible_node(NULL, NULL, "fsl,imx93-anatop");
|
np = of_find_compatible_node(NULL, NULL, "fsl,imx93-anatop");
|
||||||
anatop_base = of_iomap(np, 0);
|
anatop_base = devm_of_iomap(dev, np, 0, NULL);
|
||||||
of_node_put(np);
|
of_node_put(np);
|
||||||
if (WARN_ON(!anatop_base))
|
if (WARN_ON(IS_ERR(anatop_base))) {
|
||||||
return -ENOMEM;
|
ret = PTR_ERR(base);
|
||||||
|
goto unregister_hws;
|
||||||
|
}
|
||||||
|
|
||||||
clks[IMX93_CLK_AUDIO_PLL] = imx_clk_fracn_gppll("audio_pll", "osc_24m", anatop_base + 0x1200,
|
clks[IMX93_CLK_AUDIO_PLL] = imx_clk_fracn_gppll("audio_pll", "osc_24m", anatop_base + 0x1200,
|
||||||
&imx_fracn_gppll);
|
&imx_fracn_gppll);
|
||||||
@@ -298,8 +300,8 @@ static int imx93_clocks_probe(struct platform_device *pdev)
|
|||||||
np = dev->of_node;
|
np = dev->of_node;
|
||||||
base = devm_platform_ioremap_resource(pdev, 0);
|
base = devm_platform_ioremap_resource(pdev, 0);
|
||||||
if (WARN_ON(IS_ERR(base))) {
|
if (WARN_ON(IS_ERR(base))) {
|
||||||
iounmap(anatop_base);
|
ret = PTR_ERR(base);
|
||||||
return PTR_ERR(base);
|
goto unregister_hws;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(root_array); i++) {
|
for (i = 0; i < ARRAY_SIZE(root_array); i++) {
|
||||||
@@ -329,7 +331,6 @@ static int imx93_clocks_probe(struct platform_device *pdev)
|
|||||||
|
|
||||||
unregister_hws:
|
unregister_hws:
|
||||||
imx_unregister_hw_clocks(clks, IMX93_CLK_END);
|
imx_unregister_hw_clocks(clks, IMX93_CLK_END);
|
||||||
iounmap(anatop_base);
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user