mmap_region is already passed sanitized addr and len, so change the
call to do_vmi_munmap() to do_vmi_align_munmap() and inline the other
checks.
The inlining of the function and checks is an intermediate step in the
series so future patches are easier to follow.
Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
return -ENOMEM;
}
- /* Unmap any existing mapping in the area */
- error = do_vmi_munmap(&vmi, mm, addr, len, uf, false);
- if (error == -EPERM)
- return error;
- else if (error)
- return -ENOMEM;
+ /* Find the first overlapping VMA */
+ vma = vma_find(&vmi, end);
+ if (vma) {
+ /* Unmap any existing mapping in the area */
+ if (do_vmi_align_munmap(&vmi, vma, mm, addr, end, uf, false))
+ return -ENOMEM;
+ vma = NULL;
+ }
/*
* Private writable mapping: check memory availability