staging/lustre/libcfs: Do not call kthread_run in wrong state
authorOleg Drokin <green@linuxhacker.ru>
Mon, 20 Jun 2016 20:55:51 +0000 (16:55 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 20 Jun 2016 21:28:39 +0000 (14:28 -0700)
kthread_run might sleep during an allocation, and so
it's considered unsafe to call with a state that's not
RUNNABLE.
Move the state setting to after kthread_run call.

Signed-off-by: Oleg Drokin <green@linuxhacker.ru>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/lustre/lnet/libcfs/debug.c

index 75a2a42f7d0c79da984a958108e6059a1916fe1b..42b15a76918398831325518799dd758011aaf465 100644 (file)
@@ -362,12 +362,12 @@ void libcfs_debug_dumplog(void)
         * get to schedule()
         */
        init_waitqueue_entry(&wait, current);
-       set_current_state(TASK_INTERRUPTIBLE);
        add_wait_queue(&debug_ctlwq, &wait);
 
        dumper = kthread_run(libcfs_debug_dumplog_thread,
                             (void *)(long)current_pid(),
                             "libcfs_debug_dumper");
+       set_current_state(TASK_INTERRUPTIBLE);
        if (IS_ERR(dumper))
                pr_err("LustreError: cannot start log dump thread: %ld\n",
                       PTR_ERR(dumper));