aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/kthread.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/kthread.c')
-rw-r--r--kernel/kthread.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/kernel/kthread.c b/kernel/kthread.c
index 9ff173dca1ae..4ab4c3766a80 100644
--- a/kernel/kthread.c
+++ b/kernel/kthread.c
@@ -64,7 +64,7 @@ static inline struct kthread *to_kthread(struct task_struct *k)
64static struct kthread *to_live_kthread(struct task_struct *k) 64static struct kthread *to_live_kthread(struct task_struct *k)
65{ 65{
66 struct completion *vfork = ACCESS_ONCE(k->vfork_done); 66 struct completion *vfork = ACCESS_ONCE(k->vfork_done);
67 if (likely(vfork)) 67 if (likely(vfork) && try_get_task_stack(k))
68 return __to_kthread(vfork); 68 return __to_kthread(vfork);
69 return NULL; 69 return NULL;
70} 70}
@@ -425,8 +425,10 @@ void kthread_unpark(struct task_struct *k)
425{ 425{
426 struct kthread *kthread = to_live_kthread(k); 426 struct kthread *kthread = to_live_kthread(k);
427 427
428 if (kthread) 428 if (kthread) {
429 __kthread_unpark(k, kthread); 429 __kthread_unpark(k, kthread);
430 put_task_stack(k);
431 }
430} 432}
431EXPORT_SYMBOL_GPL(kthread_unpark); 433EXPORT_SYMBOL_GPL(kthread_unpark);
432 434
@@ -455,6 +457,7 @@ int kthread_park(struct task_struct *k)
455 wait_for_completion(&kthread->parked); 457 wait_for_completion(&kthread->parked);
456 } 458 }
457 } 459 }
460 put_task_stack(k);
458 ret = 0; 461 ret = 0;
459 } 462 }
460 return ret; 463 return ret;
@@ -490,6 +493,7 @@ int kthread_stop(struct task_struct *k)
490 __kthread_unpark(k, kthread); 493 __kthread_unpark(k, kthread);
491 wake_up_process(k); 494 wake_up_process(k);
492 wait_for_completion(&kthread->exited); 495 wait_for_completion(&kthread->exited);
496 put_task_stack(k);
493 } 497 }
494 ret = k->exit_code; 498 ret = k->exit_code;
495 put_task_struct(k); 499 put_task_struct(k);