bug on kmem_cache_free with the wrong cache

Signed-off-by: Daniel Micay <danielmicay@gmail.com>
Signed-off-by: anupritaisno1 <www.anuprita804@gmail.com>
This commit is contained in:
anupritaisno1 2021-12-07 05:23:48 +05:30 committed by Kreciorek
parent 0fc6163cd6
commit 8df273c856

View file

@ -510,10 +510,14 @@ static inline struct kmem_cache *cache_from_obj(struct kmem_cache *s, void *x)
return s;
cachep = virt_to_cache(x);
#ifdef CONFIG_BUG_ON_DATA_CORRUPTION
BUG_ON(cachep && cachep != s);
#else
if (WARN(cachep && cachep != s,
"%s: Wrong slab cache. %s but object is from %s\n",
__func__, s->name, cachep->name))
print_tracking(cachep, x);
#endif
return cachep;
}