Skip to content

Commit 1f57f78

Browse files
JiangJiasbebarino
authored andcommitted
clk: mediatek: clk-mt6779: 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: 710774e ("clk: mediatek: Add MT6779 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 b826810 commit 1f57f78

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

drivers/clk/mediatek/clk-mt6779.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1217,6 +1217,8 @@ static int clk_mt6779_apmixed_probe(struct platform_device *pdev)
12171217
struct device_node *node = pdev->dev.of_node;
12181218

12191219
clk_data = mtk_alloc_clk_data(CLK_APMIXED_NR_CLK);
1220+
if (!clk_data)
1221+
return -ENOMEM;
12201222

12211223
mtk_clk_register_plls(node, plls, ARRAY_SIZE(plls), clk_data);
12221224

@@ -1237,6 +1239,8 @@ static int clk_mt6779_top_probe(struct platform_device *pdev)
12371239
return PTR_ERR(base);
12381240

12391241
clk_data = mtk_alloc_clk_data(CLK_TOP_NR_CLK);
1242+
if (!clk_data)
1243+
return -ENOMEM;
12401244

12411245
mtk_clk_register_fixed_clks(top_fixed_clks, ARRAY_SIZE(top_fixed_clks),
12421246
clk_data);

0 commit comments

Comments
 (0)