git: 1673a83cbabd - stable/15 - ntsync(9): free wait state on error from copyin of the object's array

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Thu, 18 Jun 2026 04:40:01 UTC
The branch stable/15 has been updated by kib:

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

commit 1673a83cbabd25d6bbeb8065af9ea70e02a75fcb
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2026-06-15 04:31:03 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2026-06-17 18:24:57 +0000

    ntsync(9): free wait state on error from copyin of the object's array
    
    (cherry picked from commit 281e350942b26b054ba5bc820c6aae4ae0e03a38)
---
 sys/dev/ntsync/ntsync.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/sys/dev/ntsync/ntsync.c b/sys/dev/ntsync/ntsync.c
index 2d3054e0a4ee..5fba9775be0e 100644
--- a/sys/dev/ntsync/ntsync.c
+++ b/sys/dev/ntsync/ntsync.c
@@ -1210,7 +1210,7 @@ ntsync_wait_state_get(struct ntsync_wait_args *nwa, u_long cmd,
 	error = copyin((void *)(uintptr_t)nwa->objs, &state->fds[0],
 	    nwa->count * sizeof(state->fds[0]));
 	if (error != 0)
-		return (error);
+		goto error_ret;
 
 	i = 0;
 	if (nwa->alert != 0) {
@@ -1296,6 +1296,8 @@ error_out:
 		fdrop(state->fps[j], td);
 	if (state->fp_alert != NULL)
 		fdrop(state->fp_alert, td);
+error_ret:
+	free(state, M_NTSYNC);
 	return (error);
 }