]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
sunrpc: Fix potential leaks in sunrpc_cache_unhash()
authorTrond Myklebust <trondmy@gmail.com>
Mon, 6 Jan 2020 18:40:34 +0000 (13:40 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 24 Feb 2020 07:38:40 +0000 (08:38 +0100)
[ Upstream commit 1d82163714c16ebe09c7a8c9cd3cef7abcc16208 ]

When we unhash the cache entry, we need to handle any pending upcalls
by calling cache_fresh_unlocked().

Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/sunrpc/cache.c

index f740cb51802af8f2bb12a49031df172eea0f7da8..7ede1e52fd812e9c91f90301c3af827b0c3ff27b 100644 (file)
@@ -1888,7 +1888,9 @@ void sunrpc_cache_unhash(struct cache_detail *cd, struct cache_head *h)
        if (!hlist_unhashed(&h->cache_list)){
                hlist_del_init_rcu(&h->cache_list);
                cd->entries--;
+               set_bit(CACHE_CLEANED, &h->flags);
                spin_unlock(&cd->hash_lock);
+               cache_fresh_unlocked(h, cd);
                cache_put(h, cd);
        } else
                spin_unlock(&cd->hash_lock);