Skip to content

Commit 6feeb96

Browse files
xairyTim Tianyang Chen
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 <[email protected]> Cc: stable <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]> (cherry picked from commit bbf2618) Orabug: 27206874 CVE: CVE-2017-16526 Signed-off-by: Tim Tianyang Chen <[email protected]> Reviewed-by: Reviewed-by: Jack Vogel <[email protected]>
1 parent 3c1701c commit 6feeb96

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

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)