diff options
author | Catalin Marinas <catalin.marinas@arm.com> | 2009-06-11 13:23:17 +0100 |
---|---|---|
committer | Catalin Marinas <catalin.marinas@arm.com> | 2009-06-11 17:03:30 +0100 |
commit | 4374e616d28e65265a5b433ceece275449f3d2e3 (patch) | |
tree | 3261fe75f806c87b447f8273dd4c101bd656881d /mm/slob.c | |
parent | d5cff635290aec9ad7e6ee546aa4fae895361cbb (diff) | |
download | linux-4374e616d28e65265a5b433ceece275449f3d2e3.tar.gz linux-4374e616d28e65265a5b433ceece275449f3d2e3.tar.bz2 linux-4374e616d28e65265a5b433ceece275449f3d2e3.zip |
kmemleak: Add the slob memory allocation/freeing hooks
This patch adds the callbacks to kmemleak_(alloc|free) functions from the
slob allocator.
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Acked-by: Matt Mackall <mpm@selenic.com>
Acked-by: Pekka Enberg <penberg@cs.helsinki.fi>
Diffstat (limited to 'mm/slob.c')
-rw-r--r-- | mm/slob.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/mm/slob.c b/mm/slob.c index 9b1737b0787b..12f261499925 100644 --- a/mm/slob.c +++ b/mm/slob.c @@ -67,6 +67,7 @@ #include <linux/rcupdate.h> #include <linux/list.h> #include <linux/kmemtrace.h> +#include <linux/kmemleak.h> #include <asm/atomic.h> /* @@ -509,6 +510,7 @@ void *__kmalloc_node(size_t size, gfp_t gfp, int node) size, PAGE_SIZE << order, gfp, node); } + kmemleak_alloc(ret, size, 1, gfp); return ret; } EXPORT_SYMBOL(__kmalloc_node); @@ -521,6 +523,7 @@ void kfree(const void *block) if (unlikely(ZERO_OR_NULL_PTR(block))) return; + kmemleak_free(block); sp = slob_page(block); if (is_slob_page(sp)) { @@ -584,12 +587,14 @@ struct kmem_cache *kmem_cache_create(const char *name, size_t size, } else if (flags & SLAB_PANIC) panic("Cannot create slab cache %s\n", name); + kmemleak_alloc(c, sizeof(struct kmem_cache), 1, GFP_KERNEL); return c; } EXPORT_SYMBOL(kmem_cache_create); void kmem_cache_destroy(struct kmem_cache *c) { + kmemleak_free(c); slob_free(c, sizeof(struct kmem_cache)); } EXPORT_SYMBOL(kmem_cache_destroy); @@ -613,6 +618,7 @@ void *kmem_cache_alloc_node(struct kmem_cache *c, gfp_t flags, int node) if (c->ctor) c->ctor(b); + kmemleak_alloc_recursive(b, c->size, 1, c->flags, flags); return b; } EXPORT_SYMBOL(kmem_cache_alloc_node); @@ -635,6 +641,7 @@ static void kmem_rcu_free(struct rcu_head *head) void kmem_cache_free(struct kmem_cache *c, void *b) { + kmemleak_free_recursive(b, c->flags); if (unlikely(c->flags & SLAB_DESTROY_BY_RCU)) { struct slob_rcu *slob_rcu; slob_rcu = b + (c->size - sizeof(struct slob_rcu)); |