nfsd: only unhash DRC entries that are in the hashtable

It's not safe to call hlist_del() on a newly initialized hlist_node.
That leads to a NULL pointer dereference. Only do that if the entry
is hashed.

Signed-off-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
This commit is contained in:
Jeff Layton 2013-03-18 10:49:07 -04:00 committed by J. Bruce Fields
parent a937536b86
commit a517b608fa

View File

@ -102,7 +102,8 @@ nfsd_reply_cache_free_locked(struct svc_cacherep *rp)
{ {
if (rp->c_type == RC_REPLBUFF) if (rp->c_type == RC_REPLBUFF)
kfree(rp->c_replvec.iov_base); kfree(rp->c_replvec.iov_base);
hlist_del(&rp->c_hash); if (!hlist_unhashed(&rp->c_hash))
hlist_del(&rp->c_hash);
list_del(&rp->c_lru); list_del(&rp->c_lru);
--num_drc_entries; --num_drc_entries;
kmem_cache_free(drc_slab, rp); kmem_cache_free(drc_slab, rp);