Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mm: make vm_area_dup() actually copy the old vma data

.. and re-initialize th eanon_vma_chain head.

This removes some boiler-plate from the users, and also makes it clear
why it didn't need use the 'zalloc()' version.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

+7 -11
+7 -3
kernel/fork.c
··· 315 315 316 316 struct vm_area_struct *vm_area_dup(struct vm_area_struct *orig) 317 317 { 318 - return kmem_cache_alloc(vm_area_cachep, GFP_KERNEL); 318 + struct vm_area_struct *new = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL); 319 + 320 + if (new) { 321 + *new = *orig; 322 + INIT_LIST_HEAD(&new->anon_vma_chain); 323 + } 324 + return new; 319 325 } 320 326 321 327 void vm_area_free(struct vm_area_struct *vma) ··· 479 473 tmp = vm_area_dup(mpnt); 480 474 if (!tmp) 481 475 goto fail_nomem; 482 - *tmp = *mpnt; 483 - INIT_LIST_HEAD(&tmp->anon_vma_chain); 484 476 retval = vma_dup_policy(mpnt, tmp); 485 477 if (retval) 486 478 goto fail_nomem_policy;
-7
mm/mmap.c
··· 2624 2624 if (!new) 2625 2625 return -ENOMEM; 2626 2626 2627 - /* most fields are the same, copy all, and then fixup */ 2628 - *new = *vma; 2629 - 2630 - INIT_LIST_HEAD(&new->anon_vma_chain); 2631 - 2632 2627 if (new_below) 2633 2628 new->vm_end = addr; 2634 2629 else { ··· 3200 3205 new_vma = vm_area_dup(vma); 3201 3206 if (!new_vma) 3202 3207 goto out; 3203 - *new_vma = *vma; 3204 3208 new_vma->vm_start = addr; 3205 3209 new_vma->vm_end = addr + len; 3206 3210 new_vma->vm_pgoff = pgoff; 3207 3211 if (vma_dup_policy(vma, new_vma)) 3208 3212 goto out_free_vma; 3209 - INIT_LIST_HEAD(&new_vma->anon_vma_chain); 3210 3213 if (anon_vma_clone(new_vma, vma)) 3211 3214 goto out_free_mempol; 3212 3215 if (new_vma->vm_file)
-1
mm/nommu.c
··· 1476 1476 } 1477 1477 1478 1478 /* most fields are the same, copy all, and then fixup */ 1479 - *new = *vma; 1480 1479 *region = *vma->vm_region; 1481 1480 new->vm_region = region; 1482 1481