Commit 24adf127 authored by Rusty Russell's avatar Rusty Russell

lguest: avoid using NR_CPUS as a bounds check.

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: default avatarRusty Russell <rusty@rustcorp.com.au>
parent 48e4043d
...@@ -102,7 +102,7 @@ static ssize_t read(struct file *file, char __user *user, size_t size,loff_t*o) ...@@ -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) 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. */ /* 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; return -EINVAL;
/* Set up this CPU's id, and pointer back to the lguest struct. */ /* Set up this CPU's id, and pointer back to the lguest struct. */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment