Received: by 2002:a05:6358:53a8:b0:117:f937:c515 with SMTP id z40csp3351747rwe; Sun, 16 Apr 2023 18:11:05 -0700 (PDT) X-Google-Smtp-Source: AKy350YxGn7DyM2yXZ6p/F0tkNMROK2nv4HsSryXnVtTfpeoEALzCrb5+w4F28uBo/GiZp9ZNrS6 X-Received: by 2002:a17:902:ab59:b0:19a:aa0e:2d67 with SMTP id ij25-20020a170902ab5900b0019aaa0e2d67mr8599264plb.32.1681693865060; Sun, 16 Apr 2023 18:11:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681693865; cv=none; d=google.com; s=arc-20160816; b=l7s7hJ8lS3nFyoZ5z2pjIC3QM6eCrV9wxBh/x9x281fUYYLBclgJ7bhs4rqtTE3EiY 4uL6LP1ZI3eGTi91ViC7CQ9jnRdGIhsqxwOfV+7vPv9u2zqRihY2u19/kLdUImbyWyMZ 8biRTLY3hpW0TSCsm73Qp/BNdvX3uSH4rwFPLpLIVTvQmfzRfCR1HOFKBOqIwB9mOYad zWICoQHr+5QeiJLwqVwD5wmxu1+XVvXbiXRoZ3wzmPRxDKiXNLovNT5DzoPqW0tfCKtB zDD84SoLQpzhrZftuyelz2AsmDL4EKS+rtLkpgNArl40QvtjyS7ekdroOj+fZvFpYD90 4qAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=vtgkDSGGXh5D5EWBb1g4lLqBgy8KgoEu83yaKxnCXGM=; b=j1Tw00L70E49si21pefD9pt0B5qxqICRDVGVcK6LbKOg8TsuTOAuArrTNzfeLz9kmG u2u/QguYEkeiqEqXHxXcojOeiOIpeU9PqbzFEjTzQreawyS42tapnTqZ6Q/LAiR2dQIH qLdmUFUawE72qYUid48STLS159PT9tWGGRu9aFyiUA8RJvn7UuBwWWJc9QIYFmUgAKe0 Qqr+B9etGWmDpKI6m3icL7447l2NF6NEqAawsGYl0oMDWUbhcbXzge8d1vYNzHL2DF/C PO4JcZ22rAokJ6DLEZiO5EVQHbFdwYrF+oBTmyMHbv2ioC1nlmlT8fOfTGaGsvKMewBo nZbg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e11-20020a170902ed8b00b001a647aadbe0si10441488plj.568.2023.04.16.18.10.45; Sun, 16 Apr 2023 18:11:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229644AbjDQAja (ORCPT + 99 others); Sun, 16 Apr 2023 20:39:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229484AbjDQAj3 (ORCPT ); Sun, 16 Apr 2023 20:39:29 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5523A2116 for ; Sun, 16 Apr 2023 17:39:28 -0700 (PDT) Received: from kwepemm600020.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Q07PQ4p75zSs0x; Mon, 17 Apr 2023 08:35:22 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by kwepemm600020.china.huawei.com (7.193.23.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Mon, 17 Apr 2023 08:39:25 +0800 From: Peng Zhang To: , , CC: , , , ZhangPeng Subject: [PATCH] userfaultfd: use helper function range_in_vma() Date: Mon, 17 Apr 2023 08:39:19 +0800 Message-ID: <20230417003919.930515-1-zhangpeng362@huawei.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemm600020.china.huawei.com (7.193.23.147) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: ZhangPeng We could use range_in_vma() to check if dst_start, dst_start + len are within the dst_vma range. Minor readability improvement. Signed-off-by: ZhangPeng --- mm/userfaultfd.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/mm/userfaultfd.c b/mm/userfaultfd.c index 11cfd82c6726..e97a0b4889fc 100644 --- a/mm/userfaultfd.c +++ b/mm/userfaultfd.c @@ -31,11 +31,7 @@ struct vm_area_struct *find_dst_vma(struct mm_struct *dst_mm, struct vm_area_struct *dst_vma; dst_vma = find_vma(dst_mm, dst_start); - if (!dst_vma) - return NULL; - - if (dst_start < dst_vma->vm_start || - dst_start + len > dst_vma->vm_end) + if (!range_in_vma(dst_vma, dst_start, dst_start + len)) return NULL; /* -- 2.25.1