lguest: avoid using NR_CPUS as a bounds check.
authorRusty Russell <rusty@rustcorp.com.au>
Sat, 3 May 2008 02:50:51 +0000 (21:50 -0500)
committerRusty Russell <rusty@rustcorp.com.au>
Fri, 2 May 2008 11:50:51 +0000 (21:50 +1000)
NR_CPUS (being a host number) is an arbitrary limit for the Guest.
Using the array size directly (which currently happes to be NR_CPUS)
is more futureproof.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
drivers/lguest/lguest_user.c

index 645e6e040bfbeab46bad83b52f9bdf42a310d788..4017701a178877da0f4258cc92f442ce4b1ec1de 100644 (file)
@@ -102,7 +102,7 @@ static ssize_t read(struct file *file, char __user *user, size_t size,loff_t*o)
 static int lg_cpu_start(struct lg_cpu *cpu, unsigned id, unsigned long start_ip)
 {
        /* We have a limited number the number of CPUs in the lguest struct. */
-       if (id >= NR_CPUS)
+       if (id >= ARRAY_SIZE(cpu->lg->cpus))
                return -EINVAL;
 
        /* Set up this CPU's id, and pointer back to the lguest struct. */