]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blobdiff - mm/mmap.c
mm/mmap.c: expand_downwards: don't require the gap if !vm_prev
[mirror_ubuntu-zesty-kernel.git] / mm / mmap.c
index 9fabd8c82f383265d511ef03703e42393a0d988c..09c728a1eeee248b3af92f401db9c3b037f64570 100644 (file)
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -2312,7 +2312,6 @@ int expand_downwards(struct vm_area_struct *vma,
 {
        struct mm_struct *mm = vma->vm_mm;
        struct vm_area_struct *prev;
-       unsigned long gap_addr;
        int error;
 
        address &= PAGE_MASK;
@@ -2321,15 +2320,12 @@ int expand_downwards(struct vm_area_struct *vma,
                return error;
 
        /* Enforce stack_guard_gap */
-       gap_addr = address - stack_guard_gap;
-       if (gap_addr > address)
-               return -ENOMEM;
        prev = vma->vm_prev;
-       if (prev && prev->vm_end > gap_addr &&
+       /* Check that both stack segments have the same anon_vma? */
+       if (prev && !(prev->vm_flags & VM_GROWSDOWN) &&
                        (prev->vm_flags & (VM_WRITE|VM_READ|VM_EXEC))) {
-               if (!(prev->vm_flags & VM_GROWSDOWN))
+               if (address - prev->vm_end < stack_guard_gap)
                        return -ENOMEM;
-               /* Check that both stack segments have the same anon_vma? */
        }
 
        /* We must make sure the anon_vma is allocated. */