]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
optee: Remove vma linked list walk
authorLiam R. Howlett <Liam.Howlett@Oracle.com>
Mon, 4 Jan 2021 19:43:36 +0000 (14:43 -0500)
committerMatthew Wilcox (Oracle) <willy@infradead.org>
Sat, 30 Oct 2021 03:38:43 +0000 (23:38 -0400)
Use the VMA iterator instead.  Change the calling convention of
__check_mem_type() to pass in the mm instead of the first vma in the
range.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
drivers/tee/optee/call.c

index 945f03da0223724b1aed3948b73d55816b63fac2..bdbf992d3b49dcd9f395f557264100627863fc29 100644 (file)
@@ -580,15 +580,18 @@ static bool is_normal_memory(pgprot_t p)
 #endif
 }
 
-static int __check_mem_type(struct vm_area_struct *vma, unsigned long end)
+static int __check_mem_type(struct mm_struct *mm, unsigned long start,
+                               unsigned long end)
 {
-       while (vma && is_normal_memory(vma->vm_page_prot)) {
-               if (vma->vm_end >= end)
-                       return 0;
-               vma = vma->vm_next;
+       struct vm_area_struct *vma;
+       VMA_ITERATOR(vmi, mm, start);
+
+       for_each_vma_range(vmi, vma, end) {
+               if (!is_normal_memory(vma->vm_page_prot))
+                       return -EINVAL;
        }
 
-       return -EINVAL;
+       return 0;
 }
 
 static int check_mem_type(unsigned long start, size_t num_pages)
@@ -604,8 +607,7 @@ static int check_mem_type(unsigned long start, size_t num_pages)
                return 0;
 
        mmap_read_lock(mm);
-       rc = __check_mem_type(find_vma(mm, start),
-                             start + num_pages * PAGE_SIZE);
+       rc = __check_mem_type(mm, start, start + num_pages * PAGE_SIZE);
        mmap_read_unlock(mm);
 
        return rc;