git: 00cf2f3092e4 - stable/14 - vfs_lookup.c: only call ktrcapfail() if KTRACE is enabled

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Wed, 15 May 2024 13:22:01 UTC
The branch stable/14 has been updated by kib:

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

commit 00cf2f3092e462b8840b8cb9c3d86c471da065e5
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2024-04-24 19:06:14 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2024-05-15 13:21:35 +0000

    vfs_lookup.c: only call ktrcapfail() if KTRACE is enabled
    
    (cherry picked from commit 6b0cf2a2379b86b67269ed4549057cd6d69490e5)
---
 sys/kern/vfs_lookup.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/sys/kern/vfs_lookup.c b/sys/kern/vfs_lookup.c
index f7fb986d4472..b7f751a364ce 100644
--- a/sys/kern/vfs_lookup.c
+++ b/sys/kern/vfs_lookup.c
@@ -88,8 +88,14 @@ static void NDVALIDATE_impl(struct nameidata *, int);
 	ndp->ni_cnd.cn_flags |= ISRESTARTED;				\
 } while (0)
 
+#ifdef KTRACE
+#define	NIKTRCAPFAIL(path)	ktrcapfail(CAPFAIL_NAMEI, (path))
+#else
+#define	NIKTRCAPFAIL(path)
+#endif
+
 #define	NI_CAP_VIOLATION(ndp, path)	do {			\
-	ktrcapfail(CAPFAIL_NAMEI, (path));			\
+	NIKTRCAPFAIL(path);					\
 	(ndp)->ni_lcf &= ~NI_LCF_KTR_FLAGS;			\
 } while (0)