clk: sunxi: fix overflow when setting up divided factors
Emilio López
maintainerPATCH 1/1 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.
---
Hi Mike,
Is there any chance you can include this oneliner on your second part of the pull request to Linus?
Cheers,
Emilio
drivers/clk/sunxi/clk-sunxi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/sunxi/clk-sunxi.c +1 -1
@@ -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;
Signature · 1 line
1.8.5.3
PATCH 1/1 clk: sunxi: fix overflow when setting up divided factors
Quoting Emilio L?pez (2014-01-24 17:32:41)
Quoted 5 lines
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.
Quoted 8 lines
Reported-by Dan Carpenter <[email protected]>Signed-off-by Emilio L?pez <[email protected]>---
Hi Mike,
Is there any chance you can include this oneliner on your second part of the pull request to Linus?
Done.
Regards,
Mike
Quoted 24 lines
Cheers,
Emilio
drivers/clk/sunxi/clk-sunxi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/clk/sunxi/clk-sunxi.c +1
-1@@ -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;Signature · 1 line
1.8.5.3