clk: at91: sam9x7: Use kmalloc_array() instead of kmalloc()
Subsystems (2)
PATCH RESEND 1/1 clk: at91: sam9x7: Use kmalloc_array() instead of kmalloc()
Replace kmalloc with kmalloc array in clk/at91/sam9x7.c. Refactor to new API, for cases with dynamic size calculations inside kmalloc().
Resend is to correct previously sent patches mailing address.
---
drivers/clk/at91/sam9x7.c +3 -3
@@ -748,9 +748,9 @@ static void __init sam9x7_pmc_setup(struct device_node *np)if (!sam9x7_pmc)return ; - clk_mux_buffer =kmalloc (sizeof (void *) * - (ARRAY_SIZE (sam9x7_gck)), -GFP_KERNEL ); + clk_mux_buffer =kmalloc_array (ARRAY_SIZE (sam9x7_gck), +sizeof (void *), +GFP_KERNEL );if (!clk_mux_buffer) goto err_free;
Signature · 1 line
2.39.5 (Apple Git-154)
Quoted 3 lines · Sidharth Seela
Replace kmalloc with kmalloc array in
clk/at91/sam9x7.c. Refactor to new API, for cases with dynamic size calculations insidekmalloc().
This following line doesn't belong in commit log.
Can you add details on how you tested this patch and also how you found the problem to begin with.
Quoted 13 lines
Resend is to correct previously sent patches mailing address.
Signed-off-by Sidharth Seela <[email protected]>---
drivers/clk/at91/sam9x7.c +0
-0@@ -748,9 +748,9 @@ static void __init sam9x7_pmc_setup(struct device_node *np)if (!sam9x7_pmc)return ;
drivers/clk/at91/sam9x7.c static void __init sam9x7_pmc_setup(struct device_node *np) · line 756
Quoted 10 lines
drivers/clk/at91/sam9x7.c +3
-3- clk_mux_buffer =kmalloc (sizeof (void *) * - (ARRAY_SIZE (sam9x7_gck)), -GFP_KERNEL ); + clk_mux_buffer =kmalloc_array (ARRAY_SIZE (sam9x7_gck), +sizeof (void *), +GFP_KERNEL );if (!clk_mux_buffer) goto err_free;
thanks,
-- Shuah
Quoted 1 line · Shuah Khan
This following line doesn't belong in commit log.
This was one of my early patches. It won't happen again.
Quoted 2 lines
Can you add details on how you tested this patch and also how you found the problem to begin with.
I used grep to find instances of kmalloc and went through the ones with size calculations inside them.
I did compile testing, My mistake, I forgot to add request for test. I would like to retract this patch for the same.
Signature · 3 lines
Thanks, Sidharth Seela www.realtimedesign.org
Claudiu Beznea
maintainerHi, Sidharth,
Quoted 12 lines · Sidharth Seela
Replace kmalloc with kmalloc array in
clk/at91/sam9x7.c. Refactor to new API, for cases with dynamic size calculations insidekmalloc().Resend is to correct previously sent patches mailing address.
Signed-off-by Sidharth Seela <[email protected]>---
drivers/clk/at91/sam9x7.c +0
-0
drivers/clk/at91/sam9x7.c static void __init sam9x7_pmc_setup(struct device_node *np) · line 752
Quoted 8 lines
drivers/clk/at91/sam9x7.c +2
-3@@ -748,9 +748,9 @@ static void __init sam9x7_pmc_setup(struct device_node *np)if (!sam9x7_pmc)return ; - clk_mux_buffer =kmalloc (sizeof (void *) * - (ARRAY_SIZE (sam9x7_gck)), -GFP_KERNEL ); + clk_mux_buffer = kmalloc_array(ARRAY_SIZE(sam9x7_gck), + sizeof(void *),
sizeof(*clk_mux_buffer)
Also, this line should be aligned on the above "(". Please run checkpatch.pl.
Could you please update the other at91 clock drivers?
drivers/clk/at91/sam9x7.c static void __init sam9x7_pmc_setup(struct device_node *np) · line 753
Quoted 1 line
drivers/clk/at91/sam9x7.c +1
-0+ GFP_KERNEL);
This like could fit on the above one.
Thank you,
Claudiu
Quoted 3 lines
drivers/clk/at91/sam9x7.c +0
-0if (!clk_mux_buffer) goto err_free;