git: 1491ab351b45 - main - ntsync(9): do not double-free obj when finstall() failed

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

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

commit 1491ab351b45b1c727eeed40027f7b5074b19ff5
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2026-06-15 04:41:53 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2026-06-15 12:57:41 +0000

    ntsync(9): do not double-free obj when finstall() failed
    
    Reported by:    Alex S <iwtcex@gmail.com>
    Sponsored by:   The FreeBSD Foundation
    MFC after:      3 days
---
 sys/dev/ntsync/ntsync.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/sys/dev/ntsync/ntsync.c b/sys/dev/ntsync/ntsync.c
index 5fba9775be0e..2dec2f68aa80 100644
--- a/sys/dev/ntsync/ntsync.c
+++ b/sys/dev/ntsync/ntsync.c
@@ -297,6 +297,7 @@ ntsync_create_obj(struct ntsync_obj *obj, struct fileops *fops,
 	finit(fp, FREAD | FWRITE, DTYPE_NTSYNC, obj, fops);
 	error = finstall(td, fp, &fd, 0, NULL);
 	if (error != 0) {
+		finit(fp, FREAD | FWRITE, DTYPE_NONE, NULL, &badfileops);
 		NTSYNC_PRIV_LOCK(priv);
 		MPASS(priv->objs_cnt > 0);
 		priv->objs_cnt--;