Skip to content

Commit 3db7285

Browse files
Bosi Zhangbebarino
authored andcommitted
clk: mediatek: fix of_iomap memory leak
Smatch reports: drivers/clk/mediatek/clk-mtk.c:583 mtk_clk_simple_probe() warn: 'base' from of_iomap() not released on lines: 496. This problem was also found in linux-next. In mtk_clk_simple_probe(), base is not released when handling errors if clk_data is not existed, which may cause a leak. So free_base should be added here to release base. Fixes: c58cd0e ("clk: mediatek: Add mtk_clk_simple_probe() to simplify clock providers") Signed-off-by: Bosi Zhang <[email protected]> Reviewed-by: Dongliang Mu <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Stephen Boyd <[email protected]>
1 parent 18eb864 commit 3db7285

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

drivers/clk/mediatek/clk-mtk.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -500,8 +500,10 @@ static int __mtk_clk_simple_probe(struct platform_device *pdev,
500500
num_clks += mcd->num_mux_clks + mcd->num_divider_clks;
501501

502502
clk_data = mtk_alloc_clk_data(num_clks);
503-
if (!clk_data)
504-
return -ENOMEM;
503+
if (!clk_data) {
504+
r = -ENOMEM;
505+
goto free_base;
506+
}
505507

506508
if (mcd->fixed_clks) {
507509
r = mtk_clk_register_fixed_clks(mcd->fixed_clks,
@@ -599,6 +601,7 @@ static int __mtk_clk_simple_probe(struct platform_device *pdev,
599601
mcd->num_fixed_clks, clk_data);
600602
free_data:
601603
mtk_free_clk_data(clk_data);
604+
free_base:
602605
if (mcd->shared_io && base)
603606
iounmap(base);
604607
return r;

0 commit comments

Comments
 (0)