All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tcp: correct kcalloc usage
       [not found] <for-27-patch8-1@bga.com>
@ 2008-07-10 21:25 ` Milton Miller
  2008-07-10 23:51   ` David Miller
  2008-07-10 21:28 ` [PATCH] alsa: " Milton Miller
  1 sibling, 1 reply; 3+ messages in thread
From: Milton Miller @ 2008-07-10 21:25 UTC (permalink / raw)
  To: netdev; +Cc: linux-kernel, Andrew Morton

kcalloc is supposed to be called with the count as its first argument and
the element size as the second.

Signed-off-by: Milton Miller <miltonm@bga.com>
---
Both arguments are size_t so does not affect correctness.  This
callsite is during module_init and therefore not performance critical.
Another patch will optimize the case when the count is variable but
the size is fixed.

diff --git a/net/ipv4/tcp_probe.c b/net/ipv4/tcp_probe.c
index 5ff0ce6..7ddc30f 100644
--- a/net/ipv4/tcp_probe.c
+++ b/net/ipv4/tcp_probe.c
@@ -224,7 +224,7 @@ static __init int tcpprobe_init(void)
 	if (bufsize < 0)
 		return -EINVAL;
 
-	tcp_probe.log = kcalloc(sizeof(struct tcp_log), bufsize, GFP_KERNEL);
+	tcp_probe.log = kcalloc(bufsize, sizeof(struct tcp_log), GFP_KERNEL);
 	if (!tcp_probe.log)
 		goto err0;
 

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

* [PATCH] alsa: correct kcalloc usage
       [not found] <for-27-patch8-1@bga.com>
  2008-07-10 21:25 ` [PATCH] tcp: correct kcalloc usage Milton Miller
@ 2008-07-10 21:28 ` Milton Miller
  1 sibling, 0 replies; 3+ messages in thread
From: Milton Miller @ 2008-07-10 21:28 UTC (permalink / raw)
  To: Jaroslav Kysela; +Cc: Andrew Morton, linux-kernel

kcalloc is supposed to be called with the count as its first argument and
the element size as the second.

Signed-off-by: Milton Miller <miltonm@bga.com>
---
Both arguments are size_t so does not affect correctness.  This callsite is
during module_init and therefore not performance critical.  Another patch
will optimize the case when the count is variable but the size is fixed.

alsa-devel on bcc due to  (subscribers-only)


diff --git a/sound/pci/nm256/nm256.c b/sound/pci/nm256/nm256.c
index 7efb838..06d13e7 100644
--- a/sound/pci/nm256/nm256.c
+++ b/sound/pci/nm256/nm256.c
@@ -1302,8 +1302,8 @@ snd_nm256_mixer(struct nm256 *chip)
 		.read = snd_nm256_ac97_read,
 	};
 
-	chip->ac97_regs = kcalloc(sizeof(short),
-				  ARRAY_SIZE(nm256_ac97_init_val), GFP_KERNEL);
+	chip->ac97_regs = kcalloc(ARRAY_SIZE(nm256_ac97_init_val),
+				  sizeof(short), GFP_KERNEL);
 	if (! chip->ac97_regs)
 		return -ENOMEM;

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

* Re: [PATCH] tcp: correct kcalloc usage
  2008-07-10 21:25 ` [PATCH] tcp: correct kcalloc usage Milton Miller
@ 2008-07-10 23:51   ` David Miller
  0 siblings, 0 replies; 3+ messages in thread
From: David Miller @ 2008-07-10 23:51 UTC (permalink / raw)
  To: miltonm; +Cc: netdev, linux-kernel, akpm

From: Milton Miller <miltonm@bga.com>
Date: Thu, 10 Jul 2008 16:25:33 -0500 (CDT)

> kcalloc is supposed to be called with the count as its first argument and
> the element size as the second.
> 
> Signed-off-by: Milton Miller <miltonm@bga.com>

Applied, thanks!

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

end of thread, other threads:[~2008-07-10 23:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <for-27-patch8-1@bga.com>
2008-07-10 21:25 ` [PATCH] tcp: correct kcalloc usage Milton Miller
2008-07-10 23:51   ` David Miller
2008-07-10 21:28 ` [PATCH] alsa: " Milton Miller

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.