Skip to content

Commit

Permalink
lguest: avoid using NR_CPUS as a bounds check.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Rusty Russell committed May 2, 2008
1 parent 48e4043 commit 24adf12
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/lguest/lguest_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down

0 comments on commit 24adf12

Please sign in to comment.