git: c0c7b56d3039 - main - ntsync(4): do not double-free the alert event when a dup was detected for WAIT_ALL

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Fri, 04 Sep 2026 14:44:14 UTC
The branch main has been updated by kib:

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

commit c0c7b56d3039a75a01315d610e386a5e9eda704c
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2026-09-04 14:40:50 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2026-09-04 14:44:07 +0000

    ntsync(4): do not double-free the alert event when a dup was detected for WAIT_ALL
    
    Reported by:    Andrew Griffiths <andrew@calif.io>
    Reported by:    Chris Jarrett-Davies <chrisjd@openai.com>
    Sponsored by:   The FreeBSD Foundation
    MFC after:      1 week
---
 sys/dev/ntsync/ntsync.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/sys/dev/ntsync/ntsync.c b/sys/dev/ntsync/ntsync.c
index 2dec2f68aa80..c1c3ab6a3d6c 100644
--- a/sys/dev/ntsync/ntsync.c
+++ b/sys/dev/ntsync/ntsync.c
@@ -1263,6 +1263,8 @@ ntsync_wait_state_get(struct ntsync_wait_args *nwa, u_long cmd,
 			for (j = i + 1; j < state->obj_count; j++) {
 				if (obj == state->objs[j]) {
 					i = state->obj_count;
+					if (state->alert_event != NULL)
+						i--;
 					error = EINVAL;
 					goto error_out;
 				}