kmemtrace: trace kfree() calls with NULL or zero-length objects
authorPekka Enberg <penberg@cs.helsinki.fi>
Wed, 25 Mar 2009 09:05:57 +0000 (11:05 +0200)
committerIngo Molnar <mingo@elte.hu>
Fri, 3 Apr 2009 10:23:10 +0000 (12:23 +0200)
Impact: also output kfree(NULL) entries

This patch moves the trace_kfree() calls before the ZERO_OR_NULL_PTR
check so that we can trace call-sites that call kfree() with NULL many
times which might be an indication of a bug.

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
Cc: Eduard - Gabriel Munteanu <eduard.munteanu@linux360.ro>
LKML-Reference: <1237971957.30175.18.camel@penberg-laptop>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
mm/slab.c
mm/slob.c
mm/slub.c

index fa00fd6a644dd2f1a88c2846ed74f564fcd7cb4f..b584002850305662a665577a5b03ebe7c44a8f3b 100644 (file)
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -3773,6 +3773,8 @@ void kfree(const void *objp)
        struct kmem_cache *c;
        unsigned long flags;
 
+       trace_kfree(_RET_IP_, objp);
+
        if (unlikely(ZERO_OR_NULL_PTR(objp)))
                return;
        local_irq_save(flags);
@@ -3782,8 +3784,6 @@ void kfree(const void *objp)
        debug_check_no_obj_freed(objp, obj_size(c));
        __cache_free(c, (void *)objp);
        local_irq_restore(flags);
-
-       trace_kfree(_RET_IP_, objp);
 }
 EXPORT_SYMBOL(kfree);
 
index 00003587ebfad703e06fdd284b5dc9a1e5c61dfd..a2d4ab32198d85b9773926c27ba7fdd07adfbfe7 100644 (file)
--- a/mm/slob.c
+++ b/mm/slob.c
@@ -514,6 +514,8 @@ void kfree(const void *block)
 {
        struct slob_page *sp;
 
+       trace_kfree(_RET_IP_, block);
+
        if (unlikely(ZERO_OR_NULL_PTR(block)))
                return;
 
@@ -524,8 +526,6 @@ void kfree(const void *block)
                slob_free(m, *m + align);
        } else
                put_page(&sp->page);
-
-       trace_kfree(_RET_IP_, block);
 }
 EXPORT_SYMBOL(kfree);
 
index a98078bf738b209c328a43f18764bb056849db70..7ab54ecbd3f3a5abe50eba2c0a5dc035bf4d5efc 100644 (file)
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -2792,6 +2792,8 @@ void kfree(const void *x)
        struct page *page;
        void *object = (void *)x;
 
+       trace_kfree(_RET_IP_, x);
+
        if (unlikely(ZERO_OR_NULL_PTR(x)))
                return;
 
@@ -2802,8 +2804,6 @@ void kfree(const void *x)
                return;
        }
        slab_free(page->slab, page, object, _RET_IP_);
-
-       trace_kfree(_RET_IP_, x);
 }
 EXPORT_SYMBOL(kfree);