git: 4dc196233e40 - main - bhyve: Fix assignment of *niov2 in split_iov()

Mark Johnston <[email protected]>
Newsgroups gmane.os.freebsd.devel.cvs.src,gmane.os.freebsd.current.scm
Message-ID <[email protected]>
The branch main has been updated by markj:

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

commit 4dc196233e406cd30b9b1936adb91381f6892a6a
Author:     Mark Johnston <[email protected]>
AuthorDate: 2026-08-05 18:58:32 +0000
Commit:     Mark Johnston <[email protected]>
CommitDate: 2026-08-05 18:58:32 +0000

    bhyve: Fix assignment of *niov2 in split_iov()
    
    niov2 returns the number of entries in the iovec starting at offset
    "offset".  Here we are unconditionally setting it to 1, which of course
    isn't right.
    
    Fixes:          a28cf86c4171 ("bhyve/virtio: Rework iovec handling functions for efficiency and clarity")
    Reported by:    Claude and Ada Logics
    Reviewed by:    Hans Rosenfeld <[email protected]>
    MFC after:      1 week
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D58625
---
 usr.sbin/bhyve/iov.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/usr.sbin/bhyve/iov.c b/usr.sbin/bhyve/iov.c
index aadea1d67933..637b1f4be304 100644
--- a/usr.sbin/bhyve/iov.c
+++ b/usr.sbin/bhyve/iov.c
@@ -71,8 +71,8 @@ split_iov(struct iovec *iov, size_t *niov1, size_t offset, size_t *niov2)
 	}
 
 	/* The entry iov[count] needs to be split. */
-	*niov1 = count + 1;
 	*niov2 = *niov1 - count;
+	*niov1 = count + 1;
 	memmove(&iov[count + 1], &iov[count], sizeof(struct iovec) * (*niov2));
 	iov[count].iov_len = resid;
 	iov[count + 1].iov_base = (char *)iov[count].iov_base + resid;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.