mm: kmemleak: Don't die when memory allocation fails

When memory is leaking, it's going to be harder to allocate more memory,
making it more likely for this failure condition inside of kmemleak to
manifest itself. This is extremely frustrating since kmemleak kills
itself upon the first instance of memory allocation failure.

Bypass that and make kmemleak more resilient when memory is running low.

Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
Signed-off-by: priiii1808 <priyanshusinghal0818@gmail.com>
This commit is contained in:
Sultan Alsawaf 2019-07-06 21:15:19 -07:00 committed by Ksawlii
parent 1c19be24ee
commit b8eba3b6e6

View file

@ -421,9 +421,12 @@ static struct kmemleak_object *mem_pool_alloc(gfp_t gfp)
/* try the slab allocator first */
if (object_cache) {
object = kmem_cache_alloc(object_cache, gfp_kmemleak_mask(gfp));
if (object)
return object;
while (1) {
object = kmem_cache_alloc(object_cache,
gfp_kmemleak_mask(gfp));
if (object)
return object;
}
}
/* slab allocation failed, try the memory pool */