diff options
Diffstat (limited to 'kernel/fork.c')
-rw-r--r-- | kernel/fork.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/kernel/fork.c b/kernel/fork.c index 623259fc794d..997ac1d584f7 100644 --- a/kernel/fork.c +++ b/kernel/fork.c | |||
@@ -315,6 +315,9 @@ static void account_kernel_stack(struct task_struct *tsk, int account) | |||
315 | 315 | ||
316 | static void release_task_stack(struct task_struct *tsk) | 316 | static void release_task_stack(struct task_struct *tsk) |
317 | { | 317 | { |
318 | if (WARN_ON(tsk->state != TASK_DEAD)) | ||
319 | return; /* Better to leak the stack than to free prematurely */ | ||
320 | |||
318 | account_kernel_stack(tsk, -1); | 321 | account_kernel_stack(tsk, -1); |
319 | arch_release_thread_stack(tsk->stack); | 322 | arch_release_thread_stack(tsk->stack); |
320 | free_thread_stack(tsk); | 323 | free_thread_stack(tsk); |
@@ -1862,6 +1865,7 @@ bad_fork_cleanup_count: | |||
1862 | atomic_dec(&p->cred->user->processes); | 1865 | atomic_dec(&p->cred->user->processes); |
1863 | exit_creds(p); | 1866 | exit_creds(p); |
1864 | bad_fork_free: | 1867 | bad_fork_free: |
1868 | p->state = TASK_DEAD; | ||
1865 | put_task_stack(p); | 1869 | put_task_stack(p); |
1866 | free_task(p); | 1870 | free_task(p); |
1867 | fork_out: | 1871 | fork_out: |