提交 db939174 编写于 作者: T Trond Myklebust 提交者: Yang Yingliang

NFS: nfs_igrab_and_active must first reference the superblock

stable inclusion
from linux-4.19.169
commit df7adeee7477c865fecdd43b55aee6cca0e9bb0a

--------------------------------

commit 896567ee 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: ea7c38fe ("NFSv4: Ensure we reference the inode for return-on-close in delegreturn")
Signed-off-by: NTrond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
Signed-off-by: NCheng Jian <cj.chengjian@huawei.com>
上级 31534444
...@@ -575,12 +575,14 @@ extern int nfs4_test_session_trunk(struct rpc_clnt *, ...@@ -575,12 +575,14 @@ extern int nfs4_test_session_trunk(struct rpc_clnt *,
static inline struct inode *nfs_igrab_and_active(struct inode *inode) static inline struct inode *nfs_igrab_and_active(struct inode *inode)
{ {
inode = igrab(inode); struct super_block *sb = inode->i_sb;
if (inode != NULL && !nfs_sb_active(inode->i_sb)) {
iput(inode); if (sb && nfs_sb_active(sb)) {
inode = NULL; if (igrab(inode))
return inode;
nfs_sb_deactive(sb);
} }
return inode; return NULL;
} }
static inline void nfs_iput_and_deactive(struct inode *inode) static inline void nfs_iput_and_deactive(struct inode *inode)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册