patch-1.3.25 linux/kernel/fork.c

Next file: linux/kernel/sched.c
Previous file: linux/init/main.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v1.3.24/linux/kernel/fork.c linux/kernel/fork.c
@@ -188,6 +188,7 @@
 int do_fork(unsigned long clone_flags, unsigned long usp, struct pt_regs *regs)
 {
 	int nr;
+	int error = -ENOMEM;
 	unsigned long new_stack;
 	struct task_struct *p;
 	struct allocation_struct *alloc;
@@ -199,6 +200,7 @@
 	new_stack = get_free_page(GFP_KERNEL);
 	if (!new_stack)
 		goto bad_fork_free;
+	error = -EAGAIN;
 	nr = find_empty_process();
 	if (nr < 0)
 		goto bad_fork_free;
@@ -234,6 +236,7 @@
 	SET_LINKS(p);
 	nr_tasks++;
 
+	error = -ENOMEM;
 	/* copy all the process information */
 	copy_thread(nr, clone_flags, usp, p, regs);
 	if (copy_mm(clone_flags, alloc))
@@ -249,7 +252,12 @@
 	p->counter = current->counter >> 1;
 	wake_up_process(p);			/* do this last, just in case */
 	return p->pid;
+
 bad_fork_cleanup:
+	if (p->exec_domain && p->exec_domain->use_count)
+		(*p->exec_domain->use_count)--;
+	if (p->binfmt && p->binfmt->use_count)
+		(*p->binfmt->use_count)--;
 	task[nr] = NULL;
 	REMOVE_LINKS(p);
 	nr_tasks--;
@@ -257,5 +265,5 @@
 	free_page(new_stack);
 	free_page((long) p);
 bad_fork:
-	return -EAGAIN;
+	return error;
 }

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov with Sam's (original) version
of this