]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 4 Jun 2025 12:41:54 +0000 (14:41 +0200)
[ Upstream commit 9e8f324bd44c1fe026b582b75213de4eccfa1163 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/nfs/delegation.c

index 55cfa1c4e0a65d138c8f3fed20a15571746da387..bbd582d8a7dc93e7b52acac971f786fe8e015864 100644 (file)
@@ -297,7 +297,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);