From: Milton Miller <miltonm@bga.com>
To: Ingo Molnar <mingo@elte.hu>
Cc: <linux-kernel@vger.kernel.org>
Subject: [PATCH] sched.c: use kcalloc
Date: Fri, 12 Oct 2007 04:35:17 -0500 (CDT) [thread overview]
Message-ID: <mm-sched-3@bga.com> (raw)
In-Reply-To: <mm-sched-0@bga.com>
kcalloc checks for n * sizeof(element) overflows and it zeros.
Signed-off-by: Milton Miller <miltonm@bga.com>
Index: kernel/kernel/sched.c
===================================================================
--- kernel.orig/kernel/sched.c 2007-10-12 03:58:35.000000000 -0500
+++ kernel/kernel/sched.c 2007-10-12 03:58:38.000000000 -0500
@@ -5283,10 +5283,9 @@ static struct ctl_table sd_ctl_root[] =
static struct ctl_table *sd_alloc_ctl_entry(int n)
{
struct ctl_table *entry =
- kmalloc(n * sizeof(struct ctl_table), GFP_KERNEL);
+ kcalloc(n, sizeof(struct ctl_table), GFP_KERNEL);
BUG_ON(!entry);
- memset(entry, 0, n * sizeof(struct ctl_table));
return entry;
}
@@ -6080,7 +6079,7 @@ static int build_sched_domains(const cpu
/*
* Allocate the per-node list of sched groups
*/
- sched_group_nodes = kzalloc(sizeof(struct sched_group *)*MAX_NUMNODES,
+ sched_group_nodes = kcalloc(MAX_NUMNODES, sizeof(struct sched_group *),
GFP_KERNEL);
if (!sched_group_nodes) {
printk(KERN_WARNING "Can not alloc sched group node list\n");
next prev parent reply other threads:[~2007-10-12 9:35 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-12 9:34 [PATCH] sched domain debug sysctl fixes Milton Miller
2007-10-12 9:35 ` Milton Miller [this message]
2007-10-12 9:35 ` [PATCH] sched domain sysctl: register online cpus Milton Miller
2007-10-12 9:35 ` [PATCH] sched domain sysctl: free and rebuild when changing domains Milton Miller
2007-10-12 9:35 ` [PATCH] sched domain sysctl: don't bug on alloc failure Milton Miller
2007-10-12 9:35 ` [PATCH] sched domain sysctl: sysctl tables can have no holes Milton Miller
2007-10-12 9:54 ` [PATCH] sched domain debug sysctl fixes Milton Miller
2007-10-15 7:47 ` Ingo Molnar
2007-10-15 23:40 ` [PATCH] sched domain sysctl: free kstrdup allocations Milton Miller
2007-10-16 8:44 ` Ingo Molnar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=mm-sched-3@bga.com \
--to=miltonm@bga.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox