Skip to content

Commit 896567e

Browse files
author
Trond Myklebust
committed
NFS: nfs_igrab_and_active must first reference the superblock
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>
1 parent 113aac6 commit 896567e

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

fs/nfs/internal.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -599,12 +599,14 @@ extern void nfs4_test_session_trunk(struct rpc_clnt *clnt,
599599

600600
static inline struct inode *nfs_igrab_and_active(struct inode *inode)
601601
{
602-
inode = igrab(inode);
603-
if (inode != NULL && !nfs_sb_active(inode->i_sb)) {
604-
iput(inode);
605-
inode = NULL;
602+
struct super_block *sb = inode->i_sb;
603+
604+
if (sb && nfs_sb_active(sb)) {
605+
if (igrab(inode))
606+
return inode;
607+
nfs_sb_deactive(sb);
606608
}
607-
return inode;
609+
return NULL;
608610
}
609611

610612
static inline void nfs_iput_and_deactive(struct inode *inode)

0 commit comments

Comments
 (0)