Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

sched: Fix fork() error path to not crash

In dup_task_struct(), if arch_dup_task_struct() fails, the clean up
code fails to clean up correctly.  That's because the clean up
code depends on unininitalized ti->task pointer.  We fix this
by making sure that the task and thread_info know about each other
before we attempt to take the error path.

Signed-off-by: Salman Qazi <>
Signed-off-by: Peter Zijlstra <>
Signed-off-by: Ingo Molnar <>
  • Loading branch information...
commit 164c33c6adee609b8b9062cce4c10f764d0dce13 1 parent 9e85a6f
@sqazi sqazi authored Ingo Molnar committed
Showing with 8 additions and 3 deletions.
  1. +8 −3 kernel/fork.c
11 kernel/fork.c
@@ -304,12 +304,17 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
err = arch_dup_task_struct(tsk, orig);
- if (err)
- goto out;
+ /*
+ * We defer looking at err, because we will need this setup
+ * for the clean up path to work correctly.
+ */
tsk->stack = ti;
setup_thread_stack(tsk, orig);
+ if (err)
+ goto out;
stackend = end_of_stack(tsk);
Please sign in to comment.
Something went wrong with that request. Please try again.