Commit 79576102 authored by Christoph Lameter's avatar Christoph Lameter Committed by Pekka Enberg

mm/slub: Add debugging to verify correct cache use on kmem_cache_free()

Add additional debugging to check that the objects is actually from the cache
the caller claims. Doing so currently trips up some other debugging code. It
takes a lot to infer from that what was happening.
Reviewed-by: default avatarGlauber Costa <glommer@parallels.com>
Signed-off-by: default avatarChristoph Lameter <cl@linux.com>
[ penberg@kernel.org: Use pr_err() ]
Signed-off-by: default avatarPekka Enberg <penberg@kernel.org>
parent e21827aa
...@@ -2614,6 +2614,13 @@ void kmem_cache_free(struct kmem_cache *s, void *x) ...@@ -2614,6 +2614,13 @@ void kmem_cache_free(struct kmem_cache *s, void *x)
page = virt_to_head_page(x); page = virt_to_head_page(x);
if (kmem_cache_debug(s) && page->slab != s) {
pr_err("kmem_cache_free: Wrong slab cache. %s but object"
" is from %s\n", page->slab->name, s->name);
WARN_ON_ONCE(1);
return;
}
slab_free(s, page, x, _RET_IP_); slab_free(s, page, x, _RET_IP_);
trace_kmem_cache_free(_RET_IP_, x); trace_kmem_cache_free(_RET_IP_, x);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment