git: a82308abab86 - main - nfs_clvnops.c: Fix access to v_mount when vnode unlocked

From: Rick Macklem <rmacklem_at_FreeBSD.org>
Date: Sat, 01 Oct 2022 23:31:14 UTC
The branch main has been updated by rmacklem:

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

commit a82308abab86740e9bc37499bd2a13568764d7a0
Author:     Rick Macklem <rmacklem@FreeBSD.org>
AuthorDate: 2022-10-01 23:30:07 +0000
Commit:     Rick Macklem <rmacklem@FreeBSD.org>
CommitDate: 2022-10-01 23:30:07 +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().
    
    MFC after:      1 week
---
 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 686b69eaa637..eeffce65a7db 100644
--- a/sys/fs/nfsclient/nfs_clvnops.c
+++ b/sys/fs/nfsclient/nfs_clvnops.c
@@ -3417,11 +3417,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);
+		return (EOPNOTSUPP);
+	}
 	if ((VFSTONFS(vp->v_mount)->nm_flag & NFSMNT_NOLOCKD) != 0) {
 		size = VTONFS(vp)->n_size;
 		NFSVOPUNLOCK(vp);