summaryrefslogtreecommitdiffstats
path: root/kernel/fork.c
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2016-11-14 08:53:56 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2016-11-14 08:53:56 +0100
commitce0347c2b089eb6ad6c14ab628a0ba5eb42f1492 (patch)
treeac46f6168ebf7d44e33903f35f699cda2ec21ace /kernel/fork.c
parentabbdc56b17d662ae710bc0c30cf0d0e9da805fd4 (diff)
parenta25f0944ba9b1d8a6813fd6f1a86f1bd59ac25a6 (diff)
downloadlinux-ce0347c2b089eb6ad6c14ab628a0ba5eb42f1492.tar.gz
linux-ce0347c2b089eb6ad6c14ab628a0ba5eb42f1492.tar.bz2
linux-ce0347c2b089eb6ad6c14ab628a0ba5eb42f1492.zip
Merge 4.9-rc5 into staging-next
We want the staging/iio fixes in here as well to resolve issues and merge problems. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'kernel/fork.c')
-rw-r--r--kernel/fork.c4
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)
static void release_task_stack(struct task_struct *tsk)
{
+ if (WARN_ON(tsk->state != TASK_DEAD))
+ return; /* Better to leak the stack than to free prematurely */
+
account_kernel_stack(tsk, -1);
arch_release_thread_stack(tsk->stack);
free_thread_stack(tsk);
@@ -1862,6 +1865,7 @@ bad_fork_cleanup_count:
atomic_dec(&p->cred->user->processes);
exit_creds(p);
bad_fork_free:
+ p->state = TASK_DEAD;
put_task_stack(p);
free_task(p);
fork_out: