git: 1045352f1503 - main - cache: only assert on flags when dealing with EMPTYPATH

From: Mateusz Guzik <mjg_at_FreeBSD.org>
Date: Sun, 17 Oct 2021 08:45:21 UTC
The branch main has been updated by mjg:

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

commit 1045352f150346ba422b3a3ce6344fc694bc3aa4
Author:     Mateusz Guzik <mjg@FreeBSD.org>
AuthorDate: 2021-10-17 08:40:16 +0000
Commit:     Mateusz Guzik <mjg@FreeBSD.org>
CommitDate: 2021-10-17 08:42:47 +0000

    cache: only assert on flags when dealing with EMPTYPATH
    
    Reported by:    syzbot+bd48ee0843206a09e6b8@syzkaller.appspotmail.com
    Fixes:          7dd419cabc6bb9e0 ("cache: add empty path support")
---
 sys/kern/vfs_cache.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sys/kern/vfs_cache.c b/sys/kern/vfs_cache.c
index c1a3b0dab1e8..656f446b7394 100644
--- a/sys/kern/vfs_cache.c
+++ b/sys/kern/vfs_cache.c
@@ -4787,13 +4787,14 @@ cache_fplookup_emptypath(struct cache_fpl *fpl)
 	tvp_seqc = fpl->tvp_seqc;
 
 	MPASS(*cnp->cn_pnbuf == '\0');
-	MPASS((cnp->cn_flags & (LOCKPARENT | WANTPARENT)) == 0);
 
 	if (__predict_false((cnp->cn_flags & EMPTYPATH) == 0)) {
 		cache_fpl_smr_exit(fpl);
 		return (cache_fpl_handled_error(fpl, ENOENT));
 	}
 
+	MPASS((cnp->cn_flags & (LOCKPARENT | WANTPARENT)) == 0);
+
 	tvs = vget_prep_smr(tvp);
 	cache_fpl_smr_exit(fpl);
 	if (__predict_false(tvs == VGET_NONE)) {