patch-2.0.33 linux/kernel/fork.c

Next file: linux/mm/filemap.c
Previous file: linux/kernel/exit.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.0.32/linux/kernel/fork.c linux/kernel/fork.c
@@ -86,7 +86,7 @@
 	for (mpnt = current->mm->mmap ; mpnt ; mpnt = mpnt->vm_next) {
 		tmp = (struct vm_area_struct *) kmalloc(sizeof(struct vm_area_struct), GFP_KERNEL);
 		if (!tmp) {
-			exit_mmap(mm);
+			/* exit_mmap is called by the caller */
 			return -ENOMEM;
 		}
 		*tmp = *mpnt;
@@ -101,12 +101,10 @@
 			tmp->vm_prev_share = mpnt;
 		}
 		if (copy_page_range(mm, current->mm, tmp)) {
-			if (mpnt->vm_next_share == tmp) {
-				tmp->vm_prev_share->vm_next_share = tmp->vm_next_share;
-				tmp->vm_next_share->vm_prev_share = tmp->vm_prev_share;	
-			}
-			kfree(tmp);
-			exit_mmap(mm);
+			/* link into the linked list for exit_mmap */
+			*p = tmp;
+			p = &tmp->vm_next;
+			/* exit_mmap is called by the caller */
 			return -ENOMEM;
 		}
 		if (tmp->vm_ops && tmp->vm_ops->open)

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov