Skip to content

Commit

Permalink
sched: domain sysctl fixes: use kcalloc()
Browse files Browse the repository at this point in the history
kcalloc checks for n * sizeof(element) overflows and it zeros.

Signed-off-by: Milton Miller <miltonm@bga.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
  • Loading branch information
Milton Miller authored and Ingo Molnar committed Oct 15, 2007
1 parent 0dbee3a commit 5cf9f06
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions kernel/sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -5243,10 +5243,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;
}
Expand Down Expand Up @@ -6018,7 +6017,7 @@ static int build_sched_domains(const cpumask_t *cpu_map)
/*
* 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");
Expand Down

0 comments on commit 5cf9f06

Please sign in to comment.