Skip to content

Commit 858a195

Browse files
Liu Shixinakpm00
authored andcommitted
mm: kmemleak: add __find_and_remove_object()
Add new __find_and_remove_object() without kmemleak_lock protect, it is in preparation for the next patch. Link: https://lkml.kernel.org/r/20231018102952.3339837-7-liushixin2@huawei.com Signed-off-by: Liu Shixin <liushixin2@huawei.com> Acked-by: Catalin Marinas <catalin.marinas@arm.com> Cc: Kefeng Wang <wangkefeng.wang@huawei.com> Cc: Patrick Wang <patrick.wang.shcn@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent 2e1d473 commit 858a195

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

mm/kmemleak.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,19 @@ static void __remove_object(struct kmemleak_object *object)
583583
object->del_state |= DELSTATE_REMOVED;
584584
}
585585

586+
static struct kmemleak_object *__find_and_remove_object(unsigned long ptr,
587+
int alias,
588+
bool is_phys)
589+
{
590+
struct kmemleak_object *object;
591+
592+
object = __lookup_object(ptr, alias, is_phys);
593+
if (object)
594+
__remove_object(object);
595+
596+
return object;
597+
}
598+
586599
/*
587600
* Look up an object in the object search tree and remove it from both
588601
* object_tree_root (or object_phys_tree_root) and object_list. The
@@ -596,9 +609,7 @@ static struct kmemleak_object *find_and_remove_object(unsigned long ptr, int ali
596609
struct kmemleak_object *object;
597610

598611
raw_spin_lock_irqsave(&kmemleak_lock, flags);
599-
object = __lookup_object(ptr, alias, is_phys);
600-
if (object)
601-
__remove_object(object);
612+
object = __find_and_remove_object(ptr, alias, is_phys);
602613
raw_spin_unlock_irqrestore(&kmemleak_lock, flags);
603614

604615
return object;

0 commit comments

Comments
 (0)