Skip to content

Commit

Permalink
sched: domain sysctl fixes: use for_each_online_cpu()
Browse files Browse the repository at this point in the history
init_sched_domain_sysctl was walking cpus 0-n and referencing per_cpu
variables.  If the cpus_possible mask is not contigious this will result
in a crash referencing unallocated data.  If the online mask is not
contigious then we would show offline cpus and miss online ones.

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 5cf9f06 commit 97b6ea7
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion kernel/sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -5326,11 +5326,12 @@ static void init_sched_domain_sysctl(void)

sd_ctl_dir[0].child = entry;

for (i = 0; i < cpu_num; i++, entry++) {
for_each_online_cpu(i) {
snprintf(buf, 32, "cpu%d", i);
entry->procname = kstrdup(buf, GFP_KERNEL);
entry->mode = 0555;
entry->child = sd_alloc_ctl_cpu_table(i);
entry++;
}
sd_sysctl_header = register_sysctl_table(sd_ctl_root);
}
Expand Down

0 comments on commit 97b6ea7

Please sign in to comment.