From: Liam R. Howlett <Liam.Howlett@Oracle.com>
Date: Wed, 10 Feb 2021 14:33:59 +0000 (-0500)
Subject: mm/mprotect: Fix adcfbd7698558a linked list removal
X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=5063e3169f3ff37e67fa461234e78744ca2d7ae5;p=users%2Fjedix%2Flinux-maple.git

mm/mprotect: Fix adcfbd7698558a linked list removal

Use mas_find() in do_mprotect_pkey to find the next vma to better align
with what happened with the old API

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
---

diff --git a/mm/mprotect.c b/mm/mprotect.c
index d9479609f1b5d..5292675e29e4f 100644
--- a/mm/mprotect.c
+++ b/mm/mprotect.c
@@ -550,8 +550,7 @@ static int do_mprotect_pkey(unsigned long start, size_t len,
 	if ((pkey != -1) && !mm_pkey_is_allocated(current->mm, pkey))
 		goto out;
 
-	mas_set(&mas, start);
-	vma = mas_walk(&mas);
+	vma = mas_find(&mas, -1);
 	error = -ENOMEM;
 	if (!vma)
 		goto out;
@@ -635,7 +634,7 @@ static int do_mprotect_pkey(unsigned long start, size_t len,
 		if (nstart >= end)
 			goto out;
 
-		vma = mas_next(&mas, ULONG_MAX);
+		vma = mas_next(&mas, -1);
 		if (!vma || vma->vm_start != nstart) {
 			error = -ENOMEM;
 			goto out;