We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0c183d9 commit 405c075Copy full SHA for 405c075
kernel/fork.c
@@ -315,6 +315,9 @@ static void account_kernel_stack(struct task_struct *tsk, int account)
315
316
static void release_task_stack(struct task_struct *tsk)
317
{
318
+ if (WARN_ON(tsk->state != TASK_DEAD))
319
+ return; /* Better to leak the stack than to free prematurely */
320
+
321
account_kernel_stack(tsk, -1);
322
arch_release_thread_stack(tsk->stack);
323
free_thread_stack(tsk);
@@ -1862,6 +1865,7 @@ static __latent_entropy struct task_struct *copy_process(
1862
1865
atomic_dec(&p->cred->user->processes);
1863
1866
exit_creds(p);
1864
1867
bad_fork_free:
1868
+ p->state = TASK_DEAD;
1869
put_task_stack(p);
1870
free_task(p);
1871
fork_out:
0 commit comments