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: Ruchit <ruchitmarathe@gmail.com>
tirimbino
Sultan Alsawaf 5 years ago committed by Ruchit
parent f5addfd149
commit cf3c9a0fd2
  1. 9
      mm/kmemleak.c

@ -564,11 +564,10 @@ static struct kmemleak_object *create_object(unsigned long ptr, size_t size,
struct kmemleak_object *object, *parent;
struct rb_node **link, *rb_parent;
object = kmem_cache_alloc(object_cache, gfp_kmemleak_mask(gfp));
if (!object) {
pr_warn("Cannot allocate a kmemleak_object structure\n");
kmemleak_disable();
return NULL;
while (1) {
object = kmem_cache_alloc(object_cache, gfp_kmemleak_mask(gfp));
if (object)
break;
}
INIT_LIST_HEAD(&object->object_list);

Loading…
Cancel
Save