Pārlūkot izejas kodu

clk: sunxi: fix overflow when setting up divided factors

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>
Emilio López 12 gadi atpakaļ
vecāks
revīzija
d1933689aa
1 mainītis faili ar 1 papildinājumiem un 1 dzēšanām
  1. 1 1
      drivers/clk/sunxi/clk-sunxi.c

+ 1 - 1
drivers/clk/sunxi/clk-sunxi.c

@@ -875,7 +875,7 @@ static void __init sunxi_divs_clk_setup(struct device_node *node,
 	if (!clk_data)
 	if (!clk_data)
 		return;
 		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)
 	if (!clks)
 		goto free_clkdata;
 		goto free_clkdata;