[PATCH] clk/mediatek: fix missing null-check for mt8135

From: Chengfeng Ye
Date: Sat Oct 30 2021 - 10:03:13 EST


The return pointer of mtk_alloc_clk_data could
be null, adding null check for all the call sites.

Signed-off-by: Chengfeng Ye <cyeaa@xxxxxxxxxxxxxx>
---
drivers/clk/mediatek/clk-mt8135.c | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/drivers/clk/mediatek/clk-mt8135.c b/drivers/clk/mediatek/clk-mt8135.c
index 9b4b645aea99..41c0baab6240 100644
--- a/drivers/clk/mediatek/clk-mt8135.c
+++ b/drivers/clk/mediatek/clk-mt8135.c
@@ -526,6 +526,8 @@ static void __init mtk_topckgen_init(struct device_node *node)
}

clk_data = mtk_alloc_clk_data(CLK_TOP_NR_CLK);
+ if (!clk_data)
+ return;

mtk_clk_register_factors(root_clk_alias, ARRAY_SIZE(root_clk_alias), clk_data);
mtk_clk_register_factors(top_divs, ARRAY_SIZE(top_divs), clk_data);
@@ -547,6 +549,8 @@ static void __init mtk_infrasys_init(struct device_node *node)
int r;

clk_data = mtk_alloc_clk_data(CLK_INFRA_NR_CLK);
+ if (!clk_data)
+ return;

mtk_clk_register_gates(node, infra_clks, ARRAY_SIZE(infra_clks),
clk_data);
@@ -575,6 +579,8 @@ static void __init mtk_pericfg_init(struct device_node *node)
}

clk_data = mtk_alloc_clk_data(CLK_PERI_NR_CLK);
+ if (!clk_data)
+ return;

mtk_clk_register_gates(node, peri_gates, ARRAY_SIZE(peri_gates),
clk_data);
--
2.17.1