nfsd: only unhash DRC entries that are in the hashtable
authorJeff Layton <jlayton@redhat.com>
Mon, 18 Mar 2013 14:49:07 +0000 (10:49 -0400)
committerJ. Bruce Fields <bfields@redhat.com>
Mon, 18 Mar 2013 18:58:32 +0000 (14:58 -0400)
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>
fs/nfsd/nfscache.c

index 62c1ee128aebafbd82e70863e57caa74de804e13..18509bd6f587bf42e79b27b1e63cd9549bb85a55 100644 (file)
@@ -102,7 +102,8 @@ nfsd_reply_cache_free_locked(struct svc_cacherep *rp)
 {
        if (rp->c_type == RC_REPLBUFF)
                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);
        --num_drc_entries;
        kmem_cache_free(drc_slab, rp);