Skip to content

Commit

Permalink
clk: st: fix handling result of of_property_count_strings
Browse files Browse the repository at this point in the history
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/2046107

Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
  • Loading branch information
Andrzej Hajda authored and Stephen Boyd committed Oct 1, 2015
1 parent 8334c0e commit a1c22a4
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions drivers/clk/st/clk-flexgen.c
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ static void __init st_of_flexgen_setup(struct device_node *np)
int num_parents, i;
spinlock_t *rlock = NULL;
unsigned long flex_flags = 0;
int ret;

pnode = of_get_parent(np);
if (!pnode)
Expand All @@ -285,13 +286,13 @@ static void __init st_of_flexgen_setup(struct device_node *np)
if (!clk_data)
goto err;

clk_data->clk_num = of_property_count_strings(np ,
"clock-output-names");
if (clk_data->clk_num <= 0) {
ret = of_property_count_strings(np, "clock-output-names");
if (ret <= 0) {
pr_err("%s: Failed to get number of output clocks (%d)",
__func__, clk_data->clk_num);
goto err;
}
clk_data->clk_num = ret;

clk_data->clks = kcalloc(clk_data->clk_num, sizeof(struct clk *),
GFP_KERNEL);
Expand Down

0 comments on commit a1c22a4

Please sign in to comment.