Skip to content

Commit 188d070

Browse files
Aiiimerabelvesa
authored andcommitted
clk: imx: clk-imx8mn: fix memory leak in imx8mn_clocks_probe
Use devm_of_iomap() instead of of_iomap() to automatically handle the unused ioremap region. If any error occurs, regions allocated by kzalloc() will leak, but using devm_kzalloc() instead will automatically free the memory using devm_kfree(). Fixes: daeb145 ("clk: imx: imx8mn: Switch to clk_hw based API") Fixes: 96d6392 ("clk: imx: Add support for i.MX8MN clock driver") Signed-off-by: Hao Luo <[email protected]> Reviewed-by: Dongliang Mu <[email protected]> Reviewed-by: Peng Fan <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Abel Vesa <[email protected]>
1 parent 6e6bb16 commit 188d070

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

drivers/clk/imx/clk-imx8mn.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ static int imx8mn_clocks_probe(struct platform_device *pdev)
323323
void __iomem *base;
324324
int ret;
325325

326-
clk_hw_data = kzalloc(struct_size(clk_hw_data, hws,
326+
clk_hw_data = devm_kzalloc(dev, struct_size(clk_hw_data, hws,
327327
IMX8MN_CLK_END), GFP_KERNEL);
328328
if (WARN_ON(!clk_hw_data))
329329
return -ENOMEM;
@@ -340,10 +340,10 @@ static int imx8mn_clocks_probe(struct platform_device *pdev)
340340
hws[IMX8MN_CLK_EXT4] = imx_get_clk_hw_by_name(np, "clk_ext4");
341341

342342
np = of_find_compatible_node(NULL, NULL, "fsl,imx8mn-anatop");
343-
base = of_iomap(np, 0);
343+
base = devm_of_iomap(dev, np, 0, NULL);
344344
of_node_put(np);
345-
if (WARN_ON(!base)) {
346-
ret = -ENOMEM;
345+
if (WARN_ON(IS_ERR(base))) {
346+
ret = PTR_ERR(base);
347347
goto unregister_hws;
348348
}
349349

0 commit comments

Comments
 (0)