Skip to content

Commit 0884393

Browse files
JiangJiasbebarino
authored andcommitted
clk: mediatek: clk-mt7629-eth: 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 606f636 commit 0884393

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

drivers/clk/mediatek/clk-mt7629-eth.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ static int clk_mt7629_ethsys_init(struct platform_device *pdev)
7777
int r;
7878

7979
clk_data = mtk_alloc_clk_data(CLK_ETH_NR_CLK);
80+
if (!clk_data)
81+
return -ENOMEM;
8082

8183
mtk_clk_register_gates(&pdev->dev, node, eth_clks,
8284
CLK_ETH_NR_CLK, clk_data);
@@ -100,6 +102,8 @@ static int clk_mt7629_sgmiisys_init(struct platform_device *pdev)
100102
int r;
101103

102104
clk_data = mtk_alloc_clk_data(CLK_SGMII_NR_CLK);
105+
if (!clk_data)
106+
return -ENOMEM;
103107

104108
mtk_clk_register_gates(&pdev->dev, node, sgmii_clks[id++],
105109
CLK_SGMII_NR_CLK, clk_data);

0 commit comments

Comments
 (0)