NFSv4: Check for delegation validity in nfs_start_delegation_return_locked()
authorTrond Myklebust <trond.myklebust@hammerspace.com>
Thu, 27 Mar 2025 23:20:53 +0000 (19:20 -0400)
committerTrond Myklebust <trond.myklebust@hammerspace.com>
Fri, 28 Mar 2025 20:38:05 +0000 (16:38 -0400)
Check that the delegation is still attached after taking the spin lock
in nfs_start_delegation_return_locked().

Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
fs/nfs/delegation.c

index 325ba0663a6de24fe9d6e53196c3154f053431ee..8bdbc4dca89ca62e5763d6aaf6df3938b20c2128 100644 (file)
@@ -307,7 +307,8 @@ nfs_start_delegation_return_locked(struct nfs_inode *nfsi)
        if (delegation == NULL)
                goto out;
        spin_lock(&delegation->lock);
-       if (!test_and_set_bit(NFS_DELEGATION_RETURNING, &delegation->flags)) {
+       if (delegation->inode &&
+           !test_and_set_bit(NFS_DELEGATION_RETURNING, &delegation->flags)) {
                clear_bit(NFS_DELEGATION_RETURN_DELAYED, &delegation->flags);
                /* Refcount matched in nfs_end_delegation_return() */
                ret = nfs_get_delegation(delegation);