nmi_backtrace: do a local dump_stack() instead of a self-NMI
[cascardo/linux.git] / kernel / kthread.c
index 9ff173d..4ab4c37 100644 (file)
@@ -64,7 +64,7 @@ static inline struct kthread *to_kthread(struct task_struct *k)
 static struct kthread *to_live_kthread(struct task_struct *k)
 {
        struct completion *vfork = ACCESS_ONCE(k->vfork_done);
-       if (likely(vfork))
+       if (likely(vfork) && try_get_task_stack(k))
                return __to_kthread(vfork);
        return NULL;
 }
@@ -425,8 +425,10 @@ void kthread_unpark(struct task_struct *k)
 {
        struct kthread *kthread = to_live_kthread(k);
 
-       if (kthread)
+       if (kthread) {
                __kthread_unpark(k, kthread);
+               put_task_stack(k);
+       }
 }
 EXPORT_SYMBOL_GPL(kthread_unpark);
 
@@ -455,6 +457,7 @@ int kthread_park(struct task_struct *k)
                                wait_for_completion(&kthread->parked);
                        }
                }
+               put_task_stack(k);
                ret = 0;
        }
        return ret;
@@ -490,6 +493,7 @@ int kthread_stop(struct task_struct *k)
                __kthread_unpark(k, kthread);
                wake_up_process(k);
                wait_for_completion(&kthread->exited);
+               put_task_stack(k);
        }
        ret = k->exit_code;
        put_task_struct(k);