All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ALSA: ctxf: Use kcalloc instead of kzalloc to allocate array
@ 2011-11-29 21:08 Thomas Meyer
  2011-12-06 12:28   ` Takashi Iwai
  0 siblings, 1 reply; 3+ messages in thread
From: Thomas Meyer @ 2011-11-29 21:08 UTC (permalink / raw)
  To: perex, tiwai, alsa-devel, linux-kernel

The advantage of kcalloc is, that will prevent integer overflows which could
result from the multiplication of number of elements and size and it is also
a bit nicer to read.

The semantic patch that makes this change is available
in https://lkml.org/lkml/2011/11/25/107

Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
---

diff -u -p a/sound/pci/ctxfi/ctsrc.c b/sound/pci/ctxfi/ctsrc.c
--- a/sound/pci/ctxfi/ctsrc.c 2011-11-13 11:08:15.090921741 +0100
+++ b/sound/pci/ctxfi/ctsrc.c 2011-11-28 20:14:46.651112893 +0100
@@ -437,7 +437,7 @@ get_src_rsc(struct src_mgr *mgr, const s
 
 	/* Allocate mem for master src resource */
 	if (MEMRD == desc->mode)
-		src = kzalloc(sizeof(*src)*desc->multi, GFP_KERNEL);
+		src = kcalloc(desc->multi, sizeof(*src), GFP_KERNEL);
 	else
 		src = kzalloc(sizeof(*src), GFP_KERNEL);
 

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

* Re: [PATCH] ALSA: ctxf: Use kcalloc instead of kzalloc to allocate array
  2011-11-29 21:08 [PATCH] ALSA: ctxf: Use kcalloc instead of kzalloc to allocate array Thomas Meyer
@ 2011-12-06 12:28   ` Takashi Iwai
  0 siblings, 0 replies; 3+ messages in thread
From: Takashi Iwai @ 2011-12-06 12:28 UTC (permalink / raw)
  To: Thomas Meyer; +Cc: perex, alsa-devel, linux-kernel

At Tue, 29 Nov 2011 22:08:00 +0100,
Thomas Meyer wrote:
> 
> The advantage of kcalloc is, that will prevent integer overflows which could
> result from the multiplication of number of elements and size and it is also
> a bit nicer to read.
> 
> The semantic patch that makes this change is available
> in https://lkml.org/lkml/2011/11/25/107
> 
> Signed-off-by: Thomas Meyer <thomas@m3y3r.de>

Thanks, applied both this and asihpi patches.


Takashi

> ---
> 
> diff -u -p a/sound/pci/ctxfi/ctsrc.c b/sound/pci/ctxfi/ctsrc.c
> --- a/sound/pci/ctxfi/ctsrc.c 2011-11-13 11:08:15.090921741 +0100
> +++ b/sound/pci/ctxfi/ctsrc.c 2011-11-28 20:14:46.651112893 +0100
> @@ -437,7 +437,7 @@ get_src_rsc(struct src_mgr *mgr, const s
>  
>  	/* Allocate mem for master src resource */
>  	if (MEMRD == desc->mode)
> -		src = kzalloc(sizeof(*src)*desc->multi, GFP_KERNEL);
> +		src = kcalloc(desc->multi, sizeof(*src), GFP_KERNEL);
>  	else
>  		src = kzalloc(sizeof(*src), GFP_KERNEL);
>  
> 

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

* Re: [PATCH] ALSA: ctxf: Use kcalloc instead of kzalloc to allocate array
@ 2011-12-06 12:28   ` Takashi Iwai
  0 siblings, 0 replies; 3+ messages in thread
From: Takashi Iwai @ 2011-12-06 12:28 UTC (permalink / raw)
  To: Thomas Meyer; +Cc: alsa-devel, linux-kernel

At Tue, 29 Nov 2011 22:08:00 +0100,
Thomas Meyer wrote:
> 
> The advantage of kcalloc is, that will prevent integer overflows which could
> result from the multiplication of number of elements and size and it is also
> a bit nicer to read.
> 
> The semantic patch that makes this change is available
> in https://lkml.org/lkml/2011/11/25/107
> 
> Signed-off-by: Thomas Meyer <thomas@m3y3r.de>

Thanks, applied both this and asihpi patches.


Takashi

> ---
> 
> diff -u -p a/sound/pci/ctxfi/ctsrc.c b/sound/pci/ctxfi/ctsrc.c
> --- a/sound/pci/ctxfi/ctsrc.c 2011-11-13 11:08:15.090921741 +0100
> +++ b/sound/pci/ctxfi/ctsrc.c 2011-11-28 20:14:46.651112893 +0100
> @@ -437,7 +437,7 @@ get_src_rsc(struct src_mgr *mgr, const s
>  
>  	/* Allocate mem for master src resource */
>  	if (MEMRD == desc->mode)
> -		src = kzalloc(sizeof(*src)*desc->multi, GFP_KERNEL);
> +		src = kcalloc(desc->multi, sizeof(*src), GFP_KERNEL);
>  	else
>  		src = kzalloc(sizeof(*src), GFP_KERNEL);
>  
> 

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

end of thread, other threads:[~2011-12-06 12:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-29 21:08 [PATCH] ALSA: ctxf: Use kcalloc instead of kzalloc to allocate array Thomas Meyer
2011-12-06 12:28 ` Takashi Iwai
2011-12-06 12:28   ` Takashi Iwai

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.