From: "Randy.Dunlap" <rddunlap@osdl.org>

When setting the 'cpu_isolated_map' mask, check that the user input value
is valid (in range 0 ..  NR_CPUS - 1).  Also fix up kernel-parameters.txt
for this parameter.

Signed-off-by: Randy Dunlap <rddunlap@osdl.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 25-akpm/Documentation/kernel-parameters.txt |    4 +++-
 25-akpm/kernel/sched.c                      |    4 +++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff -puN Documentation/kernel-parameters.txt~cpumask-range-check-before-using-value Documentation/kernel-parameters.txt
--- 25/Documentation/kernel-parameters.txt~cpumask-range-check-before-using-value	Fri Dec  3 13:44:13 2004
+++ 25-akpm/Documentation/kernel-parameters.txt	Fri Dec  3 13:44:13 2004
@@ -583,11 +583,13 @@ running once the system is up.
 			Format: <RDP>, <reset>, <pci_scan>, <verbosity>
 
 	isolcpus=	[KNL,SMP] Isolate CPUs from the general scheduler.
-			Format: <cpu number>, ..., <cpu number>
+			Format: <cpu number>,...,<cpu number>
 			This option can be used to specify one or more CPUs
 			to isolate from the general SMP balancing and scheduling
 			algorithms. The only way to move a process onto or off
 			an "isolated" CPU is via the CPU affinity syscalls.
+			<cpu number> begins at 0 and the maximum value is
+			"number of CPUs in system - 1".
 
 			This option is the preferred way to isolate CPUs. The
 			alternative - manually setting the CPU mask of all tasks
diff -puN kernel/sched.c~cpumask-range-check-before-using-value kernel/sched.c
--- 25/kernel/sched.c~cpumask-range-check-before-using-value	Fri Dec  3 13:44:13 2004
+++ 25-akpm/kernel/sched.c	Fri Dec  3 13:44:13 2004
@@ -36,6 +36,7 @@
 #include <linux/blkdev.h>
 #include <linux/delay.h>
 #include <linux/smp.h>
+#include <linux/threads.h>
 #include <linux/timer.h>
 #include <linux/rcupdate.h>
 #include <linux/cpu.h>
@@ -4169,7 +4170,8 @@ static int __init isolated_cpu_setup(cha
 	str = get_options(str, ARRAY_SIZE(ints), ints);
 	cpus_clear(cpu_isolated_map);
 	for (i = 1; i <= ints[0]; i++)
-		cpu_set(ints[i], cpu_isolated_map);
+		if (ints[i] < NR_CPUS)
+			cpu_set(ints[i], cpu_isolated_map);
 	return 1;
 }
 
_