]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
mm/mmap: Fix vm_pgoff in vma_shorten()
authorLiam R. Howlett <Liam.Howlett@Oracle.com>
Sat, 21 Nov 2020 01:05:02 +0000 (20:05 -0500)
committerLiam R. Howlett <Liam.Howlett@Oracle.com>
Sat, 21 Nov 2020 01:05:02 +0000 (20:05 -0500)
Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
mm/mmap.c

index 2ff7ab8a6f61953616cc03323a8d7c3731ef24d2..ba1c78bdc519e27c432acc52b0677687c84f1449 100644 (file)
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -2684,7 +2684,7 @@ void vma_shorten(struct vm_area_struct *vma, unsigned long start,
                unmap->vm_end = old_end;
                unmap->vm_next = vma->vm_next;
                unmap->vm_prev = vma;
-               unmap->vm_pgoff += ((old_start - end) >> PAGE_SHIFT);
+               unmap->vm_pgoff += ((end - old_start) >> PAGE_SHIFT);
        }
 
        vma_adjust_trans_huge(vma, start, end, 0);
@@ -2708,9 +2708,9 @@ void vma_shorten(struct vm_area_struct *vma, unsigned long start,
                vma_interval_tree_remove(vma, root);
        }
 
-       if (end == old_end) { // Altering the vm_start.
-               vma->vm_pgoff += (old_start - start) >> PAGE_SHIFT;
+       if (end == old_end) {
                vma->vm_start = start;
+               vma->vm_pgoff += (start - old_start) >> PAGE_SHIFT;
        } else {
                vma->vm_end = end;
        }