From patchwork Tue Jun 29 02:38:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 12349085 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8170EC11F67 for ; Tue, 29 Jun 2021 02:38:47 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5013161D0B for ; Tue, 29 Jun 2021 02:38:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5013161D0B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 9F54C8D00DC; Mon, 28 Jun 2021 22:38:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9CD1F8D008F; Mon, 28 Jun 2021 22:38:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8960B8D00DC; Mon, 28 Jun 2021 22:38:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0161.hostedemail.com [216.40.44.161]) by kanga.kvack.org (Postfix) with ESMTP id 66B768D008F for ; Mon, 28 Jun 2021 22:38:46 -0400 (EDT) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 620AD180ACEF3 for ; Tue, 29 Jun 2021 02:38:46 +0000 (UTC) X-FDA: 78305203452.18.E80959E Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf08.hostedemail.com (Postfix) with ESMTP id 09C218019373 for ; Tue, 29 Jun 2021 02:38:45 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id 26E7F61D08; Tue, 29 Jun 2021 02:38:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1624934325; bh=NEMFESVlv2JJ8Yx2N/qXYXAn4JTb7arqsL99zzcaj4Q=; h=Date:From:To:Subject:In-Reply-To:From; b=JKFZwD96zwpBcADkgrBUUagfvhbP8IQLruB0G9qqXxUPa5eSDJcneSSiVf4LP4b9x IfAmWrUPh6dIHSoE0UDYgWki7uLgVv0YjKCU4ILa0Njwwt3JI8HaGdnic6AOP/QAsg Hwgrp5bMcmtsShR446eX1ry0Iy3jgDfYGVriaT3c= Date: Mon, 28 Jun 2021 19:38:44 -0700 From: Andrew Morton To: akpm@linux-foundation.org, Liam.Howlett@Oracle.com, linux-mm@kvack.org, mm-commits@vger.kernel.org, torvalds@linux-foundation.org Subject: [patch 103/192] mm/mmap: use find_vma_intersection() in do_mmap() for overlap Message-ID: <20210629023844.DMnemX3qz%akpm@linux-foundation.org> In-Reply-To: <20210628193256.008961950a714730751c1423@linux-foundation.org> User-Agent: s-nail v14.8.16 X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 09C218019373 Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=JKFZwD96; spf=pass (imf08.hostedemail.com: domain of akpm@linux-foundation.org designates 198.145.29.99 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org; dmarc=none X-Stat-Signature: mzbxkrm1g5pygf576h8meksmroku6jpe X-HE-Tag: 1624934325-408369 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: From: Liam Howlett Subject: mm/mmap: use find_vma_intersection() in do_mmap() for overlap Using find_vma_intersection() avoids the need for a temporary variable and makes the code cleaner. Link: https://lkml.kernel.org/r/20210511014328.2902782-1-Liam.Howlett@Oracle.com Signed-off-by: Liam R. Howlett Reviewed-by: Andrew Morton Signed-off-by: Andrew Morton --- mm/mmap.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) --- a/mm/mmap.c~mm-mmap-use-find_vma_intersection-in-do_mmap-for-overlap +++ a/mm/mmap.c @@ -1457,9 +1457,7 @@ unsigned long do_mmap(struct file *file, return addr; if (flags & MAP_FIXED_NOREPLACE) { - struct vm_area_struct *vma = find_vma(mm, addr); - - if (vma && vma->vm_start < addr + len) + if (find_vma_intersection(mm, addr, addr + len)) return -EEXIST; }