git: 896a2b369c2a - stable/15 - namei(9): fix two ni_startdir leaks

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Tue, 17 Nov 2026 01:09:35 UTC
The branch stable/15 has been updated by kib:

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

commit 896a2b369c2a61f385895ef615b969cfd3cb3651
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2026-11-10 00:49:33 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2026-11-17 00:24:57 +0000

    namei(9): fix two ni_startdir leaks
    
    (cherry picked from commit 5feb271df85fe6bd968052d5bdd02b6d80335610)
---
 sys/kern/vfs_lookup.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/sys/kern/vfs_lookup.c b/sys/kern/vfs_lookup.c
index 2d19dc7e818d..9b000aeea65d 100644
--- a/sys/kern/vfs_lookup.c
+++ b/sys/kern/vfs_lookup.c
@@ -686,6 +686,8 @@ restart:
 	if (__predict_false(error != 0)) {
 		namei_cleanup_cnp(cnp);
 		nameicap_cleanup(ndp, error);
+		if (ndp->ni_startdir != NULL)
+			vrele(ndp->ni_startdir);
 		SDT_PROBE4(vfs, namei, lookup, return, error, NULL,
 		    false, ndp);
 		return (error);
@@ -746,6 +748,8 @@ restart:
 			}
 			namei_cleanup_cnp(cnp);
 			nameicap_cleanup(ndp, ENOENT);
+			if (ndp->ni_startdir != NULL)
+				vrele(ndp->ni_startdir);
 			SDT_PROBE4(vfs, namei, lookup, return, ENOENT, NULL,
 			    false, ndp);
 			return (ENOENT);