git: 30f0328a322e - main - vmm: don't return random error from vcpu_lock_all() if vcpu is empty

From: Gleb Smirnoff <glebius_at_FreeBSD.org>
Date: Wed, 12 Jul 2023 16:17:16 UTC
The branch main has been updated by glebius:

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

commit 30f0328a322eb17e7b6bf31a8d587a071e9421ed
Author:     Gleb Smirnoff <glebius@FreeBSD.org>
AuthorDate: 2023-07-12 16:16:40 +0000
Commit:     Gleb Smirnoff <glebius@FreeBSD.org>
CommitDate: 2023-07-12 16:16:40 +0000

    vmm: don't return random error from vcpu_lock_all() if vcpu is empty
    
    When vcpu array is empty, function would return random value from
    stack.  What I observed was -1.
    
    Reviewed by:            corvink, markj
    Differential Revision:  https://reviews.freebsd.org/D40980
---
 sys/amd64/vmm/vmm_dev.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/sys/amd64/vmm/vmm_dev.c b/sys/amd64/vmm/vmm_dev.c
index f9fcb32d8e28..74c751d7f116 100644
--- a/sys/amd64/vmm/vmm_dev.c
+++ b/sys/amd64/vmm/vmm_dev.c
@@ -187,6 +187,7 @@ vcpu_lock_all(struct vmmdev_softc *sc)
 	int error;
 	uint16_t i, j, maxcpus;
 
+	error = 0;
 	vm_slock_vcpus(sc->vm);
 	maxcpus = vm_get_maxcpus(sc->vm);
 	for (i = 0; i < maxcpus; i++) {