Skip to content

Commit 606f636

Browse files
JiangJiasbebarino
authored andcommitted
clk: mediatek: clk-mt6797: 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: 96596aa ("clk: mediatek: add clk support for MT6797") 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 1f57f78 commit 606f636

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

drivers/clk/mediatek/clk-mt6797.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,8 @@ static int mtk_topckgen_init(struct platform_device *pdev)
390390
return PTR_ERR(base);
391391

392392
clk_data = mtk_alloc_clk_data(CLK_TOP_NR);
393+
if (!clk_data)
394+
return -ENOMEM;
393395

394396
mtk_clk_register_factors(top_fixed_divs, ARRAY_SIZE(top_fixed_divs),
395397
clk_data);
@@ -545,6 +547,8 @@ static void mtk_infrasys_init_early(struct device_node *node)
545547

546548
if (!infra_clk_data) {
547549
infra_clk_data = mtk_alloc_clk_data(CLK_INFRA_NR);
550+
if (!infra_clk_data)
551+
return;
548552

549553
for (i = 0; i < CLK_INFRA_NR; i++)
550554
infra_clk_data->hws[i] = ERR_PTR(-EPROBE_DEFER);
@@ -570,6 +574,8 @@ static int mtk_infrasys_init(struct platform_device *pdev)
570574

571575
if (!infra_clk_data) {
572576
infra_clk_data = mtk_alloc_clk_data(CLK_INFRA_NR);
577+
if (!infra_clk_data)
578+
return -ENOMEM;
573579
} else {
574580
for (i = 0; i < CLK_INFRA_NR; i++) {
575581
if (infra_clk_data->hws[i] == ERR_PTR(-EPROBE_DEFER))

0 commit comments

Comments
 (0)