aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2022-12-09 18:26:49 +0000
committerJohn Baldwin <jhb@FreeBSD.org>2023-01-26 22:07:33 +0000
commita982814ef8dd0c2fb8fd935341a3cd354791d31c (patch)
tree2063a50ec4c4048348b6aa080f4e5486adc943a3
parent3bedbb1008a82641b785d58f5c0def8ce5ec5377 (diff)
downloadsrc-a982814ef8dd0c2fb8fd935341a3cd354791d31c.tar.gz
src-a982814ef8dd0c2fb8fd935341a3cd354791d31c.zip
vmm: Avoid infinite loop in vcpu_lock_all error case.
Reported by: Coverity (CIDs 1501060,1501071) Reviewed by: corvink, markj, emaste Differential Revision: https://reviews.freebsd.org/D37648 (cherry picked from commit d212d6ebb4ea3b3e9c3964c1a6d3f41817e437e1)
-rw-r--r--sys/amd64/vmm/vmm_dev.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/sys/amd64/vmm/vmm_dev.c b/sys/amd64/vmm/vmm_dev.c
index 94b462feef6a..2d8ff43a74dd 100644
--- a/sys/amd64/vmm/vmm_dev.c
+++ b/sys/amd64/vmm/vmm_dev.c
@@ -149,7 +149,7 @@ vcpu_lock_all(struct vmmdev_softc *sc)
{
struct vcpu *vcpu;
int error;
- uint16_t i, maxcpus;
+ uint16_t i, j, maxcpus;
vm_slock_vcpus(sc->vm);
maxcpus = vm_get_maxcpus(sc->vm);
@@ -163,11 +163,11 @@ vcpu_lock_all(struct vmmdev_softc *sc)
}
if (error) {
- while (--i >= 0) {
- vcpu = vm_vcpu(sc->vm, i);
+ for (j = 0; j < i; j++) {
+ vcpu = vm_vcpu(sc->vm, j);
if (vcpu == NULL)
continue;
- vcpu_unlock_one(sc, i, vcpu);
+ vcpu_unlock_one(sc, j, vcpu);
}
vm_unlock_vcpus(sc->vm);
}