Skip to contentSkip to conversation

alsa: correct kcalloc usage

PATCH New Milton Miller 2 participants 3 messages Jul 10, 2008 1 message not in the archive

Subsystems (4)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 1/1 alsa: correct kcalloc usage

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

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

sound/pci/nm256/nm256.c +2 -2
index 7efb838..06d13e7 100644
@@ -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;
#2 lore raw

PATCH 1/1 tcp: correct kcalloc usage

In reply to a message not in the archive

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

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

net/ipv4/tcp_probe.c +1 -1
index 5ff0ce6..7ddc30f 100644
@@ -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;
 
maintainer Applied
#3 lore raw

Re: [PATCH] tcp: correct kcalloc usage

From: Milton Miller <[email protected]>
Date: Thu, 10 Jul 2008 16:25:33 -0500 (CDT)

Quoted 4 lines

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

Applied, thanks!