summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/kvm/kvm_binary_stats_test.c
diff options
context:
space:
mode:
authorAndrew Jones <drjones@redhat.com>2022-06-14 11:10:41 +0300
committerPaolo Bonzini <pbonzini@redhat.com>2022-06-14 19:43:53 +0300
commitb3b7c6a6e80d8347a4a5a13a25fa314800f2cbbe (patch)
tree3254268f719d3fb347036380c8e2d1c66a99b401 /tools/testing/selftests/kvm/kvm_binary_stats_test.c
parentfcba483e82462830dd368951c0df03a95676f34d (diff)
downloadlinux-b3b7c6a6e80d8347a4a5a13a25fa314800f2cbbe.tar.xz
KVM: selftests: kvm_binary_stats_test: Fix index expressions
kvm_binary_stats_test accepts two arguments, the number of vms and number of vcpus. If these inputs are not equal then the test would likely crash for one reason or another due to using miscalculated indices for the vcpus array. Fix the index expressions by swapping the use of i and j. Signed-off-by: Andrew Jones <drjones@redhat.com> Message-Id: <20220614081041.2571511-1-drjones@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'tools/testing/selftests/kvm/kvm_binary_stats_test.c')
-rw-r--r--tools/testing/selftests/kvm/kvm_binary_stats_test.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/tools/testing/selftests/kvm/kvm_binary_stats_test.c b/tools/testing/selftests/kvm/kvm_binary_stats_test.c
index 1baabf955d63..3c2d06b61442 100644
--- a/tools/testing/selftests/kvm/kvm_binary_stats_test.c
+++ b/tools/testing/selftests/kvm/kvm_binary_stats_test.c
@@ -225,14 +225,14 @@ int main(int argc, char *argv[])
for (i = 0; i < max_vm; ++i) {
vms[i] = vm_create_barebones();
for (j = 0; j < max_vcpu; ++j)
- vcpus[j * max_vcpu + i] = __vm_vcpu_add(vms[i], j);
+ vcpus[i * max_vcpu + j] = __vm_vcpu_add(vms[i], j);
}
/* Check stats read for every VM and VCPU */
for (i = 0; i < max_vm; ++i) {
vm_stats_test(vms[i]);
for (j = 0; j < max_vcpu; ++j)
- vcpu_stats_test(vcpus[j * max_vcpu + i]);
+ vcpu_stats_test(vcpus[i * max_vcpu + j]);
}
for (i = 0; i < max_vm; ++i)