summaryrefslogtreecommitdiff
path: root/numa.c
diff options
context:
space:
mode:
authorEduardo Habkost <ehabkost@redhat.com>2015-02-12 15:23:48 -0200
committerEduardo Habkost <ehabkost@redhat.com>2015-03-19 16:01:22 -0300
commited26b92290768818371fbfd4317988eab6009ad5 (patch)
treef31e7a6df06773ca7753b5161d223a92413a7506 /numa.c
parent3e5f6234b4f45a11b7c357dde2d6da36641bc6f6 (diff)
downloadqemu-ed26b92290768818371fbfd4317988eab6009ad5.tar.gz
qemu-ed26b92290768818371fbfd4317988eab6009ad5.tar.bz2
qemu-ed26b92290768818371fbfd4317988eab6009ad5.zip
numa: Fix off-by-one error at MAX_CPUMASK_BITS check
Fix the CPU index check to ensure we don't go beyond the size of the node_cpu bitmap. CPU index is always less than MAX_CPUMASK_BITS, as documented at sysemu.h: > The following shall be true for all CPUs: > cpu->cpu_index < max_cpus <= MAX_CPUMASK_BITS Reviewed-by: Igor Mammedov <imammedo@redhat.com> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Diffstat (limited to 'numa.c')
-rw-r--r--numa.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/numa.c b/numa.c
index ffbec68fd8..13b2f01dba 100644
--- a/numa.c
+++ b/numa.c
@@ -76,9 +76,9 @@ static void numa_node_parse(NumaNodeOptions *node, QemuOpts *opts, Error **errp)
}
for (cpus = node->cpus; cpus; cpus = cpus->next) {
- if (cpus->value > MAX_CPUMASK_BITS) {
+ if (cpus->value >= MAX_CPUMASK_BITS) {
error_setg(errp, "CPU number %" PRIu16 " is bigger than %d",
- cpus->value, MAX_CPUMASK_BITS);
+ cpus->value, MAX_CPUMASK_BITS - 1);
return;
}
bitmap_set(numa_info[nodenr].node_cpu, cpus->value, 1);