Skip to content

Commit bbf2618

Browse files
xairygregkh
authored andcommitted
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: Andrey Konovalov <andreyknvl@google.com> Cc: stable <stable@vger.kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 70e743e commit bbf2618

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

Diff for: drivers/uwb/uwbd.c

+8-4
Original file line numberDiff line numberDiff line change
@@ -302,18 +302,22 @@ static int uwbd(void *param)
302302
/** Start the UWB daemon */
303303
void uwbd_start(struct uwb_rc *rc)
304304
{
305-
rc->uwbd.task = kthread_run(uwbd, rc, "uwbd");
306-
if (rc->uwbd.task == NULL)
305+
struct task_struct *task = kthread_run(uwbd, rc, "uwbd");
306+
if (IS_ERR(task)) {
307+
rc->uwbd.task = NULL;
307308
printk(KERN_ERR "UWB: Cannot start management daemon; "
308309
"UWB won't work\n");
309-
else
310+
} else {
311+
rc->uwbd.task = task;
310312
rc->uwbd.pid = rc->uwbd.task->pid;
313+
}
311314
}
312315

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

0 commit comments

Comments
 (0)