When part of an object is deleted, propagate the OBJECT_NO_SCAN flag to the 2 new created objects. Signed-off-by: George Prekas <george@xxxxxxxxxxxxx> --- mm/kmemleak.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/mm/kmemleak.c b/mm/kmemleak.c index 2b9c9ad68806..5882f60d127c 100644 --- a/mm/kmemleak.c +++ b/mm/kmemleak.c @@ -772,7 +772,7 @@ static void delete_object_full(unsigned long ptr) */ static void delete_object_part(unsigned long ptr, size_t size, bool is_phys) { - struct kmemleak_object *object; + struct kmemleak_object *object, *o1 = NULL, *o2 = NULL; unsigned long start, end; object = find_and_remove_object(ptr, 1, is_phys); @@ -792,11 +792,19 @@ static void delete_object_part(unsigned long ptr, size_t size, bool is_phys) start = object->pointer; end = object->pointer + object->size; if (ptr > start) - __create_object(start, ptr - start, object->min_count, - GFP_KERNEL, is_phys); + o1 = __create_object(start, ptr - start, object->min_count, + GFP_KERNEL, is_phys); if (ptr + size < end) - __create_object(ptr + size, end - ptr - size, object->min_count, - GFP_KERNEL, is_phys); + o2 = __create_object(ptr + size, end - ptr - size, + object->min_count, GFP_KERNEL, is_phys); + + /* Propagate the NO_SCAN flag */ + if (object->flags & OBJECT_NO_SCAN) { + if (o1) + o1->flags |= OBJECT_NO_SCAN; + if (o2) + o2->flags |= OBJECT_NO_SCAN; + } __delete_object(object); } -- 2.37.1