Blob Blame History Raw
From: Dai Ngo <dai.ngo@oracle.com>
Date: Mon, 23 Jan 2023 21:34:13 -0800
Subject: [PATCH] NFSD: fix leaked reference count of nfsd4_ssc_umount_item
Git-commit: 34e8f9ec4c9ac235f917747b23a200a5e0ec857b
Patch-mainline: v6.3
References: git-fixes

The reference count of nfsd4_ssc_umount_item is not decremented
on error conditions. This prevents the laundromat from unmounting
the vfsmount of the source file.

This patch decrements the reference count of nfsd4_ssc_umount_item
on error.

Fixes: f4e44b393389 ("NFSD: delay unmount source's export after inter-server copy completed.")
Signed-off-by: Dai Ngo <dai.ngo@oracle.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Acked-by: NeilBrown <neilb@suse.com>

---
 fs/nfsd/nfs4proc.c |   12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

--- a/fs/nfsd/nfs4proc.c
+++ b/fs/nfsd/nfs4proc.c
@@ -1700,13 +1700,17 @@ nfsd4_copy(struct svc_rqst *rqstp, struc
 out:
 	return status;
 out_err:
+	if (!copy->cp_intra) {
+		/*
+		 * Source's vfsmount of inter-copy will be unmounted
+		 * by the laundromat. Use copy instead of async_copy
+		 * since async_copy->ss_mnt might not be set yet.
+		 */
+		mntput(copy->ss_mnt);
+	}
 	if (async_copy)
 		cleanup_async_copy(async_copy);
 	status = nfserrno(-ENOMEM);
-	/*
-	 * source's vfsmount of inter-copy will be unmounted
-	 * by the laundromat
-	 */
 	goto out;
 }