Merge tag 'memory-controller-drv-5.13-2' of git://git.kernel.org/pub/scm/linux/kernel...
[linux-2.6-microblaze.git] / mm / mremap.c
index 4719269..ec8f840 100644 (file)
@@ -593,6 +593,14 @@ static unsigned long move_vma(struct vm_area_struct *vma,
                /* We always clear VM_LOCKED[ONFAULT] on the old vma */
                vma->vm_flags &= VM_LOCKED_CLEAR_MASK;
 
+               /*
+                * anon_vma links of the old vma is no longer needed after its page
+                * table has been moved.
+                */
+               if (new_vma != vma && vma->vm_start == old_addr &&
+                       vma->vm_end == (old_addr + old_len))
+                       unlink_anon_vmas(vma);
+
                /* Because we won't unmap we don't need to touch locked_vm */
                return new_addr;
        }