]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
nfsd: make use of warning provided by refcount_t
authorNeilBrown <neilb@suse.de>
Sun, 27 Oct 2024 22:04:43 +0000 (09:04 +1100)
committerChuck Lever <chuck.lever@oracle.com>
Tue, 19 Nov 2024 01:23:08 +0000 (20:23 -0500)
refcount_t, by design, checks for unwanted situations and provides
warnings.  It is rarely useful to have explicit warnings with refcount
usage.

In this case we have an explicit warning if a refcount_t reaches zero
when decremented.  Simply using refcount_dec() will provide a similar
warning and also mark the refcount_t as saturated to avoid any possible
use-after-free.

This patch drops the warning and uses refcount_dec() instead of
refcount_dec_and_test().

Signed-off-by: NeilBrown <neilb@suse.de>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
fs/nfsd/filecache.c

index 1408166222c5f963715eae8cfbf88f1c14bc1d2d..c16671135d1769618dbbddcd02a3cdb711ff01b4 100644 (file)
@@ -1050,7 +1050,7 @@ retry:
                 * the last one however, since we should hold another.
                 */
                if (nfsd_file_lru_remove(nf))
-                       WARN_ON_ONCE(refcount_dec_and_test(&nf->nf_ref));
+                       refcount_dec(&nf->nf_ref);
                goto wait_for_construction;
        }