Skip to content
This repository was archived by the owner on Dec 20, 2023. It is now read-only.

Commit c463558

Browse files
JoseExpositoSasha Levin
authored and
Sasha Levin
committed
clk: mediatek: Fix memory leaks on probe
[ Upstream commit 7a688c9 ] Handle the error branches to free memory where required. Addresses-Coverity-ID: 1491825 ("Resource leak") Signed-off-by: José Expósito <[email protected]> Reviewed-by: Chen-Yu Tsai <[email protected]> Link: https://lore.kernel.org/r/20220115183059.GA10809@elementary Signed-off-by: Stephen Boyd <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 6e13ecb commit c463558

File tree

1 file changed

+30
-6
lines changed

1 file changed

+30
-6
lines changed

Diff for: drivers/clk/mediatek/clk-mt8192.c

+30-6
Original file line numberDiff line numberDiff line change
@@ -1236,9 +1236,17 @@ static int clk_mt8192_infra_probe(struct platform_device *pdev)
12361236

12371237
r = mtk_clk_register_gates(node, infra_clks, ARRAY_SIZE(infra_clks), clk_data);
12381238
if (r)
1239-
return r;
1239+
goto free_clk_data;
1240+
1241+
r = of_clk_add_provider(node, of_clk_src_onecell_get, clk_data);
1242+
if (r)
1243+
goto free_clk_data;
1244+
1245+
return r;
12401246

1241-
return of_clk_add_provider(node, of_clk_src_onecell_get, clk_data);
1247+
free_clk_data:
1248+
mtk_free_clk_data(clk_data);
1249+
return r;
12421250
}
12431251

12441252
static int clk_mt8192_peri_probe(struct platform_device *pdev)
@@ -1253,9 +1261,17 @@ static int clk_mt8192_peri_probe(struct platform_device *pdev)
12531261

12541262
r = mtk_clk_register_gates(node, peri_clks, ARRAY_SIZE(peri_clks), clk_data);
12551263
if (r)
1256-
return r;
1264+
goto free_clk_data;
1265+
1266+
r = of_clk_add_provider(node, of_clk_src_onecell_get, clk_data);
1267+
if (r)
1268+
goto free_clk_data;
12571269

1258-
return of_clk_add_provider(node, of_clk_src_onecell_get, clk_data);
1270+
return r;
1271+
1272+
free_clk_data:
1273+
mtk_free_clk_data(clk_data);
1274+
return r;
12591275
}
12601276

12611277
static int clk_mt8192_apmixed_probe(struct platform_device *pdev)
@@ -1271,9 +1287,17 @@ static int clk_mt8192_apmixed_probe(struct platform_device *pdev)
12711287
mtk_clk_register_plls(node, plls, ARRAY_SIZE(plls), clk_data);
12721288
r = mtk_clk_register_gates(node, apmixed_clks, ARRAY_SIZE(apmixed_clks), clk_data);
12731289
if (r)
1274-
return r;
1290+
goto free_clk_data;
12751291

1276-
return of_clk_add_provider(node, of_clk_src_onecell_get, clk_data);
1292+
r = of_clk_add_provider(node, of_clk_src_onecell_get, clk_data);
1293+
if (r)
1294+
goto free_clk_data;
1295+
1296+
return r;
1297+
1298+
free_clk_data:
1299+
mtk_free_clk_data(clk_data);
1300+
return r;
12771301
}
12781302

12791303
static const struct of_device_id of_match_clk_mt8192[] = {

0 commit comments

Comments
 (0)