git: 6adf554abd1c - main - vmm: Fix handling of errors from subyte()

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Tue, 26 Dec 2023 02:04:36 UTC
The branch main has been updated by markj:

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

commit 6adf554abd1c848d2c9ab7ea8a7fb7dd20a0c186
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2023-12-26 01:43:51 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2023-12-26 02:04:01 +0000

    vmm: Fix handling of errors from subyte()
    
    subyte() returns -1 upon an error, not an errno value.
    
    MFC after:      1 week
    Fixes:  e17eca327633 ("vmm: Avoid embedding cpuset_t ioctl ABIs")
---
 sys/amd64/vmm/vmm_dev.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/sys/amd64/vmm/vmm_dev.c b/sys/amd64/vmm/vmm_dev.c
index cae15d7059cb..5214cd3f1447 100644
--- a/sys/amd64/vmm/vmm_dev.c
+++ b/sys/amd64/vmm/vmm_dev.c
@@ -629,10 +629,12 @@ vmmdev_ioctl(struct cdev *cdev, u_long cmd, caddr_t data, int fflag,
 
 				p = (uint8_t *)vmrun->cpuset +
 				    sizeof(cpuset_t);
-				while (error == 0 &&
-				    p < (uint8_t *)vmrun->cpuset +
+				while (p < (uint8_t *)vmrun->cpuset +
 				    vmrun->cpusetsize) {
-					error = subyte(p++, 0);
+					if (subyte(p++, 0) != 0) {
+						error = EFAULT;
+						break;
+					}
 				}
 			}
 		}