Be a little more verbose when kfree fails.
authorRonald G. Minnich <rminnich@google.com>
Sat, 16 Nov 2013 21:55:30 +0000 (13:55 -0800)
committerBarret Rhoden <brho@cs.berkeley.edu>
Thu, 16 Jan 2014 19:42:07 +0000 (11:42 -0800)
Print out what the canary was and what it was expected to be.
Then, hexdump 128 bytes before and after the passed in
address.

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
kern/src/kmalloc.c

index 1ec948f..dc52e4c 100644 (file)
@@ -102,6 +102,10 @@ void kfree(void *addr)
        if(addr == NULL)
                return;
        struct kmalloc_tag *tag = (struct kmalloc_tag*)(addr - KMALLOC_OFFSET);
+       if (tag->canary != KMALLOC_CANARY){
+               printk("Canary is bogus: %08lx, expected %08lx\n", tag->canary, KMALLOC_CANARY);
+               hexdump((void *)(addr-128), 256);
+       }
        assert(tag->canary == KMALLOC_CANARY);
        if (tag->flags & KMALLOC_TAG_CACHE)
                kmem_cache_free(tag->my_cache, addr - KMALLOC_OFFSET);