From patchwork Fri Mar 11 08:27:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12777598 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5F5ABC433EF for ; Fri, 11 Mar 2022 08:28:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E61398D0002; Fri, 11 Mar 2022 03:28:27 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E10E48D0001; Fri, 11 Mar 2022 03:28:27 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D003F8D0002; Fri, 11 Mar 2022 03:28:27 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.25]) by kanga.kvack.org (Postfix) with ESMTP id BE3888D0001 for ; Fri, 11 Mar 2022 03:28:27 -0500 (EST) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay13.hostedemail.com (Postfix) with ESMTP id 42EF960778 for ; Fri, 11 Mar 2022 08:28:27 +0000 (UTC) X-FDA: 79231428654.05.007DE77 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf29.hostedemail.com (Postfix) with ESMTP id 2FDB6120016 for ; Fri, 11 Mar 2022 08:28:26 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.54]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4KFJq65lFLz1GCKj; Fri, 11 Mar 2022 16:23:30 +0800 (CST) Received: from huawei.com (10.175.124.27) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Fri, 11 Mar 2022 16:28:21 +0800 From: Miaohe Lin To: CC: , , Subject: [PATCH] mm/madvise: Use vma_lookup() instead of find_vma() Date: Fri, 11 Mar 2022 16:27:31 +0800 Message-ID: <20220311082731.63513-1-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected X-Stat-Signature: 11o73g53ekcf1ndcjrezcx8ame33zcow Authentication-Results: imf29.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf29.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com X-Rspam-User: X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 2FDB6120016 X-HE-Tag: 1646987306-511450 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Using vma_lookup() verifies the start address is contained in the found vma. This results in easier to read the code. Signed-off-by: Miaohe Lin Reviewed-by: David Hildenbrand --- mm/madvise.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/madvise.c b/mm/madvise.c index 5b6d796e55de..afd68bfc77d4 100644 --- a/mm/madvise.c +++ b/mm/madvise.c @@ -883,8 +883,8 @@ static long madvise_populate(struct vm_area_struct *vma, * our VMA might have been split. */ if (!vma || start >= vma->vm_end) { - vma = find_vma(mm, start); - if (!vma || start < vma->vm_start) + vma = vma_lookup(mm, start); + if (!vma) return -ENOMEM; }