git: 281e350942b2 - main - ntsync(9): free wait state on error from copyin of the object's array

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Mon, 15 Jun 2026 12:58:44 UTC
The branch main has been updated by kib:

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

commit 281e350942b26b054ba5bc820c6aae4ae0e03a38
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2026-06-15 04:31:03 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2026-06-15 12:57:25 +0000

    ntsync(9): free wait state on error from copyin of the object's array
    
    Sponsored by:   The FreeBSD Foundation
    MFC after:      3 days
---
 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);
 }