]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
clk: sunxi: fix overflow when setting up divided factors
authorEmilio López <emilio@elopez.com.ar>
Sat, 25 Jan 2014 01:32:41 +0000 (22:32 -0300)
committerMike Turquette <mturquette@linaro.org>
Mon, 27 Jan 2014 20:28:23 +0000 (12:28 -0800)
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>
drivers/clk/sunxi/clk-sunxi.c

index 659e4ea31893a42bee5fb701d54fcbb34776ed67..abb6c5ac8a10297505a8a7f1cb1cb0d5f8eccf16 100644 (file)
@@ -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;