diff options
Diffstat (limited to 'mm/mmap.c')
-rw-r--r-- | mm/mmap.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/mm/mmap.c b/mm/mmap.c index dce1cc74ecdb..ec72f05b05f2 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -1388,12 +1388,15 @@ unsigned long mmap_region(struct file *file, unsigned long addr, 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 */ + error = do_vmi_align_munmap(&vmi, vma, mm, addr, end, uf, false); + if (error) + return error; + vma = NULL; + } /* * Private writable mapping: check memory availability |