提交 a1c22a4b 编写于 作者: A Andrzej Hajda 提交者: Stephen Boyd

clk: st: fix handling result of of_property_count_strings

The function can return negative value.

The problem has been detected using proposed semantic patch
scripts/coccinelle/tests/assign_signed_to_unsigned.cocci [1].

[1]: http://permalink.gmane.org/gmane.linux.kernel/2046107Signed-off-by: NAndrzej Hajda <a.hajda@samsung.com>
Signed-off-by: NStephen Boyd <sboyd@codeaurora.org>
上级 8334c0e7
...@@ -268,6 +268,7 @@ static void __init st_of_flexgen_setup(struct device_node *np) ...@@ -268,6 +268,7 @@ static void __init st_of_flexgen_setup(struct device_node *np)
int num_parents, i; int num_parents, i;
spinlock_t *rlock = NULL; spinlock_t *rlock = NULL;
unsigned long flex_flags = 0; unsigned long flex_flags = 0;
int ret;
pnode = of_get_parent(np); pnode = of_get_parent(np);
if (!pnode) if (!pnode)
...@@ -285,13 +286,13 @@ static void __init st_of_flexgen_setup(struct device_node *np) ...@@ -285,13 +286,13 @@ static void __init st_of_flexgen_setup(struct device_node *np)
if (!clk_data) if (!clk_data)
goto err; goto err;
clk_data->clk_num = of_property_count_strings(np , ret = of_property_count_strings(np, "clock-output-names");
"clock-output-names"); if (ret <= 0) {
if (clk_data->clk_num <= 0) {
pr_err("%s: Failed to get number of output clocks (%d)", pr_err("%s: Failed to get number of output clocks (%d)",
__func__, clk_data->clk_num); __func__, clk_data->clk_num);
goto err; goto err;
} }
clk_data->clk_num = ret;
clk_data->clks = kcalloc(clk_data->clk_num, sizeof(struct clk *), clk_data->clks = kcalloc(clk_data->clk_num, sizeof(struct clk *),
GFP_KERNEL); GFP_KERNEL);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册