Skip to content

Commit

Permalink
NFS: nfs_igrab_and_active must first reference the superblock
Browse files Browse the repository at this point in the history
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: ea7c38f ("NFSv4: Ensure we reference the inode for return-on-close in delegreturn")
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
  • Loading branch information
Trond Myklebust committed Jan 10, 2021
1 parent 113aac6 commit 896567e
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions fs/nfs/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -599,12 +599,14 @@ extern void nfs4_test_session_trunk(struct rpc_clnt *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)
Expand Down

0 comments on commit 896567e

Please sign in to comment.