Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5cf9f062 authored by Milton Miller's avatar Milton Miller Committed by Ingo Molnar
Browse files

sched: domain sysctl fixes: use kcalloc()



kcalloc checks for n * sizeof(element) overflows and it zeros.

Signed-off-by: default avatarMilton Miller <miltonm@bga.com>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent 0dbee3a6
Loading
Loading
Loading
Loading
+2 −3
Original line number Original line Diff line number Diff line
@@ -5243,10 +5243,9 @@ static struct ctl_table sd_ctl_root[] = {
static struct ctl_table *sd_alloc_ctl_entry(int n)
static struct ctl_table *sd_alloc_ctl_entry(int n)
{
{
	struct ctl_table *entry =
	struct ctl_table *entry =
		kmalloc(n * sizeof(struct ctl_table), GFP_KERNEL);
		kcalloc(n, sizeof(struct ctl_table), GFP_KERNEL);


	BUG_ON(!entry);
	BUG_ON(!entry);
	memset(entry, 0, n * sizeof(struct ctl_table));


	return entry;
	return entry;
}
}
@@ -6018,7 +6017,7 @@ static int build_sched_domains(const cpumask_t *cpu_map)
	/*
	/*
	 * Allocate the per-node list of sched groups
	 * 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);
					   GFP_KERNEL);
	if (!sched_group_nodes) {
	if (!sched_group_nodes) {
		printk(KERN_WARNING "Can not alloc sched group node list\n");
		printk(KERN_WARNING "Can not alloc sched group node list\n");