slab: Catch attempted NULL frees
authorBarret Rhoden <brho@cs.berkeley.edu>
Wed, 28 Mar 2018 18:27:03 +0000 (14:27 -0400)
committerBarret Rhoden <brho@cs.berkeley.edu>
Wed, 28 Mar 2018 20:43:05 +0000 (16:43 -0400)
If someone is using the slab interface, then they need to know if they have
an object or not.  This ain't like kfree().

Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
kern/src/slab.c

index 4581bcb..60d3867 100644 (file)
@@ -634,6 +634,7 @@ void kmem_cache_free(struct kmem_cache *kc, void *buf)
        struct kmem_depot *depot = &kc->depot;
        struct kmem_magazine *mag;
 
+       assert(buf);    /* catch bugs */
        lock_pcu_cache(pcc);
 try_free:
        if (pcc->loaded->nr_rounds < pcc->magsize) {