]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
nfsd: extra checks when freeing delegation stateids
authorJeff Layton <jlayton@kernel.org>
Mon, 26 Sep 2022 18:41:02 +0000 (14:41 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 10 Apr 2024 14:19:19 +0000 (16:19 +0200)
[ Upstream commit 895ddf5ed4c54ea9e3533606d7a8b4e4f27f95ef ]

We've had some reports of problems in the refcounting for delegation
stateids that we've yet to track down. Add some extra checks to ensure
that we've removed the object from various lists before freeing it.

Link: https://bugzilla.redhat.com/show_bug.cgi?id=2127067
Signed-off-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
fs/nfsd/nfs4state.c

index 61978ad43a0f721b770fa7757f3c973ae26735b5..d19629de2af5dcfee0e0846d5642a3af0b448660 100644 (file)
@@ -1071,7 +1071,12 @@ static struct nfs4_ol_stateid * nfs4_alloc_open_stateid(struct nfs4_client *clp)
 
 static void nfs4_free_deleg(struct nfs4_stid *stid)
 {
-       WARN_ON(!list_empty(&stid->sc_cp_list));
+       struct nfs4_delegation *dp = delegstateid(stid);
+
+       WARN_ON_ONCE(!list_empty(&stid->sc_cp_list));
+       WARN_ON_ONCE(!list_empty(&dp->dl_perfile));
+       WARN_ON_ONCE(!list_empty(&dp->dl_perclnt));
+       WARN_ON_ONCE(!list_empty(&dp->dl_recall_lru));
        kmem_cache_free(deleg_slab, stid);
        atomic_long_dec(&num_delegations);
 }