Skip to content

Commit 2befa51

Browse files
JiangJiasbebarino
authored andcommitted
clk: mediatek: clk-mt7629: Add check for mtk_alloc_clk_data
Add the check for the return value of mtk_alloc_clk_data() in order to avoid NULL pointer dereference. Fixes: 3b5e748 ("clk: mediatek: add clock support for MT7629 SoC") Signed-off-by: Jiasheng Jiang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: AngeloGioacchino Del Regno <[email protected]> Signed-off-by: Stephen Boyd <[email protected]>
1 parent 0884393 commit 2befa51

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

drivers/clk/mediatek/clk-mt7629.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,8 @@ static int mtk_topckgen_init(struct platform_device *pdev)
555555
return PTR_ERR(base);
556556

557557
clk_data = mtk_alloc_clk_data(CLK_TOP_NR_CLK);
558+
if (!clk_data)
559+
return -ENOMEM;
558560

559561
mtk_clk_register_fixed_clks(top_fixed_clks, ARRAY_SIZE(top_fixed_clks),
560562
clk_data);
@@ -579,6 +581,8 @@ static int mtk_infrasys_init(struct platform_device *pdev)
579581
struct clk_hw_onecell_data *clk_data;
580582

581583
clk_data = mtk_alloc_clk_data(CLK_INFRA_NR_CLK);
584+
if (!clk_data)
585+
return -ENOMEM;
582586

583587
mtk_clk_register_gates(&pdev->dev, node, infra_clks,
584588
ARRAY_SIZE(infra_clks), clk_data);
@@ -602,6 +606,8 @@ static int mtk_pericfg_init(struct platform_device *pdev)
602606
return PTR_ERR(base);
603607

604608
clk_data = mtk_alloc_clk_data(CLK_PERI_NR_CLK);
609+
if (!clk_data)
610+
return -ENOMEM;
605611

606612
mtk_clk_register_gates(&pdev->dev, node, peri_clks,
607613
ARRAY_SIZE(peri_clks), clk_data);

0 commit comments

Comments
 (0)