clk: mediatek: clk-mt6779: Add check for mtk_alloc_clk_data
authorJiasheng Jiang <jiasheng@iscas.ac.cn>
Tue, 12 Sep 2023 09:34:04 +0000 (17:34 +0800)
committerStephen Boyd <sboyd@kernel.org>
Thu, 19 Oct 2023 01:15:14 +0000 (18:15 -0700)
Add the check for the return value of mtk_alloc_clk_data() in order to
avoid NULL pointer dereference.

Fixes: 710774e04861 ("clk: mediatek: Add MT6779 clock support")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Link: https://lore.kernel.org/r/20230912093407.21505-2-jiasheng@iscas.ac.cn
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
drivers/clk/mediatek/clk-mt6779.c

index 3ee2f5a2319a0e7a6a7bf27359c92451bf9424ab..ffedb1fe3c672de2413ecdcd5cb5579a6b7df302 100644 (file)
@@ -1217,6 +1217,8 @@ static int clk_mt6779_apmixed_probe(struct platform_device *pdev)
        struct device_node *node = pdev->dev.of_node;
 
        clk_data = mtk_alloc_clk_data(CLK_APMIXED_NR_CLK);
+       if (!clk_data)
+               return -ENOMEM;
 
        mtk_clk_register_plls(node, plls, ARRAY_SIZE(plls), clk_data);
 
@@ -1237,6 +1239,8 @@ static int clk_mt6779_top_probe(struct platform_device *pdev)
                return PTR_ERR(base);
 
        clk_data = mtk_alloc_clk_data(CLK_TOP_NR_CLK);
+       if (!clk_data)
+               return -ENOMEM;
 
        mtk_clk_register_fixed_clks(top_fixed_clks, ARRAY_SIZE(top_fixed_clks),
                                    clk_data);