Commit bbf26183 authored by Andrey Konovalov's avatar Andrey Konovalov Committed by Greg Kroah-Hartman

uwb: properly check kthread_run return value

uwbd_start() calls kthread_run() and checks that the return value is
not NULL. But the return value is not NULL in case kthread_run() fails,
it takes the form of ERR_PTR(-EINTR).

Use IS_ERR() instead.

Also add a check to uwbd_stop().
Signed-off-by: default avatarAndrey Konovalov <andreyknvl@google.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 70e743e4
...@@ -302,17 +302,21 @@ static int uwbd(void *param) ...@@ -302,17 +302,21 @@ static int uwbd(void *param)
/** Start the UWB daemon */ /** Start the UWB daemon */
void uwbd_start(struct uwb_rc *rc) void uwbd_start(struct uwb_rc *rc)
{ {
rc->uwbd.task = kthread_run(uwbd, rc, "uwbd"); struct task_struct *task = kthread_run(uwbd, rc, "uwbd");
if (rc->uwbd.task == NULL) if (IS_ERR(task)) {
rc->uwbd.task = NULL;
printk(KERN_ERR "UWB: Cannot start management daemon; " printk(KERN_ERR "UWB: Cannot start management daemon; "
"UWB won't work\n"); "UWB won't work\n");
else } else {
rc->uwbd.task = task;
rc->uwbd.pid = rc->uwbd.task->pid; rc->uwbd.pid = rc->uwbd.task->pid;
}
} }
/* Stop the UWB daemon and free any unprocessed events */ /* Stop the UWB daemon and free any unprocessed events */
void uwbd_stop(struct uwb_rc *rc) void uwbd_stop(struct uwb_rc *rc)
{ {
if (rc->uwbd.task)
kthread_stop(rc->uwbd.task); kthread_stop(rc->uwbd.task);
uwbd_flush(rc); uwbd_flush(rc);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment