git: 690222c3f120 - stable/12 - nfs_clvnops.c: Fix access to v_mount when vnode unlocked

From: Rick Macklem <rmacklem_at_FreeBSD.org>
Date: Sat, 08 Oct 2022 23:25:40 UTC
The branch stable/12 has been updated by rmacklem:

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

commit 690222c3f1200cf4e98c4ba3053f1d10eafc22a2
Author:     Rick Macklem <rmacklem@FreeBSD.org>
AuthorDate: 2022-10-01 23:30:07 +0000
Commit:     Rick Macklem <rmacklem@FreeBSD.org>
CommitDate: 2022-10-08 23:24:50 +0000

    nfs_clvnops.c: Fix access to v_mount when vnode unlocked
    
    Commit ab17854f974b fixed access to v_mount when the
    vnode is unlocked for nfs_copy_file_range().
    
    This patch does the same for nfs_advlockasync().
    
    (cherry picked from commit a82308abab86740e9bc37499bd2a13568764d7a0)
---
 sys/fs/nfsclient/nfs_clvnops.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/sys/fs/nfsclient/nfs_clvnops.c b/sys/fs/nfsclient/nfs_clvnops.c
index 64386afccb4c..24c53de7309c 100644
--- a/sys/fs/nfsclient/nfs_clvnops.c
+++ b/sys/fs/nfsclient/nfs_clvnops.c
@@ -3320,11 +3320,13 @@ nfs_advlockasync(struct vop_advlockasync_args *ap)
 	u_quad_t size;
 	int error;
 	
-	if (NFS_ISV4(vp))
-		return (EOPNOTSUPP);
 	error = NFSVOPLOCK(vp, LK_SHARED);
 	if (error)
 		return (error);
+	if (NFS_ISV4(vp)) {
+		NFSVOPUNLOCK(vp, 0);
+		return (EOPNOTSUPP);
+	}
 	if ((VFSTONFS(vp->v_mount)->nm_flag & NFSMNT_NOLOCKD) != 0) {
 		size = VTONFS(vp)->n_size;
 		NFSVOPUNLOCK(vp, 0);