From nobody Fri Dec 19 01:14:54 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6FBD8CDB47E for ; Wed, 18 Oct 2023 09:30:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229994AbjJRJam (ORCPT ); Wed, 18 Oct 2023 05:30:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45560 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229770AbjJRJaZ (ORCPT ); Wed, 18 Oct 2023 05:30:25 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ADCE8106 for ; Wed, 18 Oct 2023 02:30:22 -0700 (PDT) Received: from dggpemm500009.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4S9QVd1WMDzrTTM; Wed, 18 Oct 2023 17:27:37 +0800 (CST) Received: from huawei.com (10.175.113.32) by dggpemm500009.china.huawei.com (7.185.36.225) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Wed, 18 Oct 2023 17:30:20 +0800 From: Liu Shixin To: Catalin Marinas , Patrick Wang , Andrew Morton , Kefeng Wang CC: , , Liu Shixin Subject: [PATCH v3 6/7] mm: kmemleak: add __find_and_remove_object() Date: Wed, 18 Oct 2023 18:29:51 +0800 Message-ID: <20231018102952.3339837-7-liushixin2@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231018102952.3339837-1-liushixin2@huawei.com> References: <20231018102952.3339837-1-liushixin2@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.175.113.32] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm500009.china.huawei.com (7.185.36.225) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Add new __find_and_remove_object() without kmemleak_lock protect, it is in preparation for the next patch. Signed-off-by: Liu Shixin Acked-by: Catalin Marinas --- mm/kmemleak.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/mm/kmemleak.c b/mm/kmemleak.c index ea34986c02b4..7c9125c18956 100644 --- a/mm/kmemleak.c +++ b/mm/kmemleak.c @@ -583,6 +583,19 @@ static void __remove_object(struct kmemleak_object *ob= ject) object->del_state |=3D DELSTATE_REMOVED; } =20 +static struct kmemleak_object *__find_and_remove_object(unsigned long ptr, + int alias, + bool is_phys) +{ + struct kmemleak_object *object; + + object =3D __lookup_object(ptr, alias, is_phys); + if (object) + __remove_object(object); + + return object; +} + /* * Look up an object in the object search tree and remove it from both * object_tree_root (or object_phys_tree_root) and object_list. The @@ -596,9 +609,7 @@ static struct kmemleak_object *find_and_remove_object(u= nsigned long ptr, int ali struct kmemleak_object *object; =20 raw_spin_lock_irqsave(&kmemleak_lock, flags); - object =3D __lookup_object(ptr, alias, is_phys); - if (object) - __remove_object(object); + object =3D __find_and_remove_object(ptr, alias, is_phys); raw_spin_unlock_irqrestore(&kmemleak_lock, flags); =20 return object; --=20 2.25.1