Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 9 Dec 2022 18:31:38 GMT
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: d212d6ebb4ea - main - vmm: Avoid infinite loop in vcpu_lock_all error case.
Message-ID:  <202212091831.2B9IVcI1024098@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by jhb:

URL: https://cgit.FreeBSD.org/src/commit/?id=d212d6ebb4ea3b3e9c3964c1a6d3f41817e437e1

commit d212d6ebb4ea3b3e9c3964c1a6d3f41817e437e1
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2022-12-09 18:26:49 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2022-12-09 18:26:49 +0000

    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
---
 sys/amd64/vmm/vmm_dev.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/sys/amd64/vmm/vmm_dev.c b/sys/amd64/vmm/vmm_dev.c
index aad4cf893114..98738b1f0692 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);
 	}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202212091831.2B9IVcI1024098>