Skip to content

Commit

Permalink
clk: sunxi: fix overflow when setting up divided factors
Browse files Browse the repository at this point in the history
Currently, we are allocating space for two pointers, when we actually
may need to store three of them (two divisors plus the original clock).
Fix this, and change sizeof(type) to sizeof(*var) to keep checkpatch.pl
happy.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Emilio López <emilio@elopez.com.ar>
Signed-off-by: Mike Turquette <mturquette@linaro.org>
  • Loading branch information
Emilio López authored and Mike Turquette committed Jan 27, 2014
1 parent 0b7f04b commit d193368
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/clk/sunxi/clk-sunxi.c
Original file line number Diff line number Diff line change
Expand Up @@ -875,7 +875,7 @@ static void __init sunxi_divs_clk_setup(struct device_node *node,
if (!clk_data)
return;

clks = kzalloc(SUNXI_DIVS_MAX_QTY * sizeof(struct clk *), GFP_KERNEL);
clks = kzalloc((SUNXI_DIVS_MAX_QTY+1) * sizeof(*clks), GFP_KERNEL);
if (!clks)
goto free_clkdata;

Expand Down

0 comments on commit d193368

Please sign in to comment.