浏览代码

clk: samsung: Initialize clock table with error pointers

Before this patch, the driver was simply zeroing the clock table, which
is incorrect, because invalid clock numbers returned NULL instead of
error pointers. This patch fixes this by changing the driver to
initialize the array with PTR_ERR(-ENOENT).

Signed-off-by: Tomasz Figa <t.figa@samsung.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
Tomasz Figa 11 年之前
父节点
当前提交
91a1263fd2
共有 1 个文件被更改,包括 6 次插入1 次删除
  1. 6 1
      drivers/clk/samsung/clk.c

+ 6 - 1
drivers/clk/samsung/clk.c

@@ -54,14 +54,19 @@ struct samsung_clk_provider *__init samsung_clk_init(struct device_node *np,
 	struct samsung_clk_provider *ctx;
 	struct samsung_clk_provider *ctx;
 	struct clk **clk_table;
 	struct clk **clk_table;
 	int ret;
 	int ret;
+	int i;
+
 	ctx = kzalloc(sizeof(struct samsung_clk_provider), GFP_KERNEL);
 	ctx = kzalloc(sizeof(struct samsung_clk_provider), GFP_KERNEL);
 	if (!ctx)
 	if (!ctx)
 		panic("could not allocate clock provider context.\n");
 		panic("could not allocate clock provider context.\n");
 
 
-	clk_table = kzalloc(sizeof(struct clk *) * nr_clks, GFP_KERNEL);
+	clk_table = kcalloc(nr_clks, sizeof(struct clk *), GFP_KERNEL);
 	if (!clk_table)
 	if (!clk_table)
 		panic("could not allocate clock lookup table\n");
 		panic("could not allocate clock lookup table\n");
 
 
+	for (i = 0; i < nr_clks; ++i)
+		clk_table[i] = ERR_PTR(-ENOENT);
+
 	ctx->reg_base = base;
 	ctx->reg_base = base;
 	ctx->clk_data.clks = clk_table;
 	ctx->clk_data.clks = clk_table;
 	ctx->clk_data.clk_num = nr_clks;
 	ctx->clk_data.clk_num = nr_clks;