git: e2ba9f0f6010 - stable/13 - nfs_clvnops.c: Fix access to v_mount when vnode unlocked

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

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

commit e2ba9f0f6010231a108ea528ed0e3864ebeb5cbe
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:29:22 +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 569327b14e41..155028a81716 100644
--- a/sys/fs/nfsclient/nfs_clvnops.c
+++ b/sys/fs/nfsclient/nfs_clvnops.c
@@ -3425,11 +3425,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);