From 66822a0c1a2894f81d2319fe603f62af404f9266 Mon Sep 17 00:00:00 2001 From: Sultan Alsawaf Date: Sat, 6 Jul 2019 21:15:19 -0700 Subject: [PATCH] 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 Signed-off-by: Ruchit --- mm/kmemleak.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/mm/kmemleak.c b/mm/kmemleak.c index 83b6ff95d2d3..57d5ac5e7937 100755 --- a/mm/kmemleak.c +++ b/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);