summaryrefslogtreecommitdiffstats
path: root/fs/nfs
diff options
context:
space:
mode:
authorTrond Myklebust <trond.myklebust@hammerspace.com>2021-01-10 15:58:08 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-01-19 18:22:37 +0100
commitdf7adeee7477c865fecdd43b55aee6cca0e9bb0a (patch)
treed295488a1123a570222f34eccd8ba92ca1d7b2a0 /fs/nfs
parentb2f9fbbc3fa20f066e20f1d676175e4af0e177ba (diff)
downloadlinux-stable-df7adeee7477c865fecdd43b55aee6cca0e9bb0a.tar.gz
linux-stable-df7adeee7477c865fecdd43b55aee6cca0e9bb0a.tar.bz2
linux-stable-df7adeee7477c865fecdd43b55aee6cca0e9bb0a.zip
NFS: nfs_igrab_and_active must first reference the superblock
commit 896567ee7f17a8a736cda8a28cc987228410a2ac upstream. Before referencing the inode, we must ensure that the superblock can be referenced. Otherwise, we can end up with iput() calling superblock operations that are no longer valid or accessible. Fixes: ea7c38fef0b7 ("NFSv4: Ensure we reference the inode for return-on-close in delegreturn") Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs/nfs')
-rw-r--r--fs/nfs/internal.h12
1 files changed, 7 insertions, 5 deletions
diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h
index 8357ff69962f..cc07189a501f 100644
--- a/fs/nfs/internal.h
+++ b/fs/nfs/internal.h
@@ -575,12 +575,14 @@ extern int nfs4_test_session_trunk(struct rpc_clnt *,
static inline struct inode *nfs_igrab_and_active(struct inode *inode)
{
- inode = igrab(inode);
- if (inode != NULL && !nfs_sb_active(inode->i_sb)) {
- iput(inode);
- inode = NULL;
+ struct super_block *sb = inode->i_sb;
+
+ if (sb && nfs_sb_active(sb)) {
+ if (igrab(inode))
+ return inode;
+ nfs_sb_deactive(sb);
}
- return inode;
+ return NULL;
}
static inline void nfs_iput_and_deactive(struct inode *inode)