]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
NFS: assert rcu_read_lock is held in nfs_start_delegation_return_locked
authorChristoph Hellwig <hch@lst.de>
Wed, 7 Jan 2026 07:26:58 +0000 (08:26 +0100)
committerAnna Schumaker <anna.schumaker@oracle.com>
Tue, 20 Jan 2026 19:49:46 +0000 (14:49 -0500)
And clean up the dereference of the delegation a bit.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Anna Schumaker <anna.schumaker@oracle.com>
fs/nfs/delegation.c

index 1f899edd427f14fb8e54aba1f41562615eb5be6f..b90d30bf7a31720a04f5371d74cb041bc59e229d 100644 (file)
@@ -318,10 +318,14 @@ static struct nfs_delegation *
 nfs_start_delegation_return_locked(struct nfs_inode *nfsi)
 {
        struct nfs_delegation *ret = NULL;
-       struct nfs_delegation *delegation = rcu_dereference(nfsi->delegation);
+       struct nfs_delegation *delegation;
+
+       lockdep_assert_in_rcu_read_lock();
+
+       delegation = rcu_dereference(nfsi->delegation);
+       if (!delegation)
+               return NULL;
 
-       if (delegation == NULL)
-               goto out;
        spin_lock(&delegation->lock);
        if (delegation->inode &&
            !test_and_set_bit(NFS_DELEGATION_RETURNING, &delegation->flags)) {
@@ -332,7 +336,6 @@ nfs_start_delegation_return_locked(struct nfs_inode *nfsi)
        spin_unlock(&delegation->lock);
        if (ret)
                nfs_clear_verifier_delegated(&nfsi->vfs_inode);
-out:
        return ret;
 }