Skip to content

Commit b826810

Browse files
JiangJiasbebarino
authored andcommitted
clk: mediatek: clk-mt6765: 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: 1aca993 ("clk: mediatek: Add MT6765 clock support") 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 0bb80ec commit b826810

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

drivers/clk/mediatek/clk-mt6765.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -737,6 +737,8 @@ static int clk_mt6765_apmixed_probe(struct platform_device *pdev)
737737
return PTR_ERR(base);
738738

739739
clk_data = mtk_alloc_clk_data(CLK_APMIXED_NR_CLK);
740+
if (!clk_data)
741+
return -ENOMEM;
740742

741743
mtk_clk_register_plls(node, plls, ARRAY_SIZE(plls), clk_data);
742744

@@ -769,6 +771,8 @@ static int clk_mt6765_top_probe(struct platform_device *pdev)
769771
return PTR_ERR(base);
770772

771773
clk_data = mtk_alloc_clk_data(CLK_TOP_NR_CLK);
774+
if (!clk_data)
775+
return -ENOMEM;
772776

773777
mtk_clk_register_fixed_clks(fixed_clks, ARRAY_SIZE(fixed_clks),
774778
clk_data);
@@ -807,6 +811,8 @@ static int clk_mt6765_ifr_probe(struct platform_device *pdev)
807811
return PTR_ERR(base);
808812

809813
clk_data = mtk_alloc_clk_data(CLK_IFR_NR_CLK);
814+
if (!clk_data)
815+
return -ENOMEM;
810816

811817
mtk_clk_register_gates(&pdev->dev, node, ifr_clks,
812818
ARRAY_SIZE(ifr_clks), clk_data);

0 commit comments

Comments
 (0)