Skip to content

Commit 5a21af1

Browse files
xairygregkh
authored andcommitted
uwb: properly check kthread_run return value
commit bbf26183b7a6236ba602f4d6a2f7cade35bba043 upstream. 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: Andrey Konovalov <andreyknvl@google.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 8b41964 commit 5a21af1

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

drivers/uwb/uwbd.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -303,18 +303,22 @@ static int uwbd(void *param)
303303
/** Start the UWB daemon */
304304
void uwbd_start(struct uwb_rc *rc)
305305
{
306-
rc->uwbd.task = kthread_run(uwbd, rc, "uwbd");
307-
if (rc->uwbd.task == NULL)
306+
struct task_struct *task = kthread_run(uwbd, rc, "uwbd");
307+
if (IS_ERR(task)) {
308+
rc->uwbd.task = NULL;
308309
printk(KERN_ERR "UWB: Cannot start management daemon; "
309310
"UWB won't work\n");
310-
else
311+
} else {
312+
rc->uwbd.task = task;
311313
rc->uwbd.pid = rc->uwbd.task->pid;
314+
}
312315
}
313316

314317
/* Stop the UWB daemon and free any unprocessed events */
315318
void uwbd_stop(struct uwb_rc *rc)
316319
{
317-
kthread_stop(rc->uwbd.task);
320+
if (rc->uwbd.task)
321+
kthread_stop(rc->uwbd.task);
318322
uwbd_flush(rc);
319323
}
320324

0 commit comments

Comments
 (0)