public inbox for linux-clk@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH RESEND] clk: at91: sam9x7: Use kmalloc_array() instead of kmalloc()
@ 2025-09-24 14:55 Sidharth Seela
  2025-10-07 21:06 ` Shuah Khan
  2025-11-08 10:00 ` Claudiu Beznea
  0 siblings, 2 replies; 4+ messages in thread
From: Sidharth Seela @ 2025-09-24 14:55 UTC (permalink / raw)
  To: mturquette, sboyd, nicolas.ferre, alexandre.belloni,
	claudiu.beznea, varshini.rajendran
  Cc: linux-clk, linux-arm-kernel, linux-kernel, skhan,
	david.hunter.linux, Sidharth Seela

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.

Signed-off-by: Sidharth Seela <sidharthseela@gmail.com>
---
diff --git a/drivers/clk/at91/sam9x7.c b/drivers/clk/at91/sam9x7.c
index ffab32b047a0..0c0a746a183d 100644
--- a/drivers/clk/at91/sam9x7.c
+++ b/drivers/clk/at91/sam9x7.c
@@ -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;
 
-- 
2.39.5 (Apple Git-154)


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH RESEND] clk: at91: sam9x7: Use kmalloc_array() instead of kmalloc()
  2025-09-24 14:55 [PATCH RESEND] clk: at91: sam9x7: Use kmalloc_array() instead of kmalloc() Sidharth Seela
@ 2025-10-07 21:06 ` Shuah Khan
  2025-10-08  3:37   ` Sidharth Seela
  2025-11-08 10:00 ` Claudiu Beznea
  1 sibling, 1 reply; 4+ messages in thread
From: Shuah Khan @ 2025-10-07 21:06 UTC (permalink / raw)
  To: Sidharth Seela, mturquette, sboyd, nicolas.ferre,
	alexandre.belloni, claudiu.beznea, varshini.rajendran
  Cc: linux-clk, linux-arm-kernel, linux-kernel, david.hunter.linux,
	Shuah Khan

On 9/24/25 08:55, Sidharth Seela wrote:
> Replace kmalloc with kmalloc array in clk/at91/sam9x7.c. Refactor to new
> API, for cases with dynamic size calculations inside kmalloc().
> 

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.

> Resend is to correct previously sent patches mailing address.


> 
> Signed-off-by: Sidharth Seela <sidharthseela@gmail.com>
> ---
> diff --git a/drivers/clk/at91/sam9x7.c b/drivers/clk/at91/sam9x7.c
> index ffab32b047a0..0c0a746a183d 100644
> --- a/drivers/clk/at91/sam9x7.c
> +++ b/drivers/clk/at91/sam9x7.c
> @@ -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;
>   

thanks,
-- Shuah

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH RESEND] clk: at91: sam9x7: Use kmalloc_array() instead of kmalloc()
  2025-10-07 21:06 ` Shuah Khan
@ 2025-10-08  3:37   ` Sidharth Seela
  0 siblings, 0 replies; 4+ messages in thread
From: Sidharth Seela @ 2025-10-08  3:37 UTC (permalink / raw)
  To: Shuah Khan
  Cc: mturquette, sboyd, nicolas.ferre, alexandre.belloni,
	claudiu.beznea, varshini.rajendran, linux-clk, linux-arm-kernel,
	linux-kernel, david.hunter.linux

On Wed, Oct 8, 2025 at 2:36 AM Shuah Khan <skhan@linuxfoundation.org> wrote:
> This following line doesn't belong in commit log.

This was one of my early patches. It won't happen again.

> 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.

-- 
Thanks,
Sidharth Seela
www.realtimedesign.org

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH RESEND] clk: at91: sam9x7: Use kmalloc_array() instead of kmalloc()
  2025-09-24 14:55 [PATCH RESEND] clk: at91: sam9x7: Use kmalloc_array() instead of kmalloc() Sidharth Seela
  2025-10-07 21:06 ` Shuah Khan
@ 2025-11-08 10:00 ` Claudiu Beznea
  1 sibling, 0 replies; 4+ messages in thread
From: Claudiu Beznea @ 2025-11-08 10:00 UTC (permalink / raw)
  To: Sidharth Seela, mturquette, sboyd, nicolas.ferre,
	alexandre.belloni, varshini.rajendran
  Cc: linux-clk, linux-arm-kernel, linux-kernel, skhan,
	david.hunter.linux

Hi, Sidharth,

On 9/24/25 17:55, Sidharth Seela wrote:
> 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.
> 
> Signed-off-by: Sidharth Seela <sidharthseela@gmail.com>
> ---
> diff --git a/drivers/clk/at91/sam9x7.c b/drivers/clk/at91/sam9x7.c
> index ffab32b047a0..0c0a746a183d 100644
> --- a/drivers/clk/at91/sam9x7.c
> +++ b/drivers/clk/at91/sam9x7.c
> @@ -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?

[1]
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/coding-style.rst

> +					GFP_KERNEL);

This like could fit on the above one.

Thank you,
Claudiu

>  	if (!clk_mux_buffer)
>  		goto err_free;
>  


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-11-08 10:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-24 14:55 [PATCH RESEND] clk: at91: sam9x7: Use kmalloc_array() instead of kmalloc() Sidharth Seela
2025-10-07 21:06 ` Shuah Khan
2025-10-08  3:37   ` Sidharth Seela
2025-11-08 10:00 ` Claudiu Beznea

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox