]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
uwb: properly check kthread_run return value
authorAndrey Konovalov <andreyknvl@google.com>
Thu, 14 Sep 2017 12:30:55 +0000 (14:30 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 18 Sep 2017 09:28:23 +0000 (11:28 +0200)
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>
drivers/uwb/uwbd.c

index 01c20a260a8b3f9d9a8ccc315d453f810eb3104c..39dd4ef53c77902db9f740ea3e88fd8bec5cb4ec 100644 (file)
@@ -302,18 +302,22 @@ static int uwbd(void *param)
 /** Start the UWB daemon */
 void uwbd_start(struct uwb_rc *rc)
 {
-       rc->uwbd.task = kthread_run(uwbd, rc, "uwbd");
-       if (rc->uwbd.task == NULL)
+       struct task_struct *task = kthread_run(uwbd, rc, "uwbd");
+       if (IS_ERR(task)) {
+               rc->uwbd.task = NULL;
                printk(KERN_ERR "UWB: Cannot start management daemon; "
                       "UWB won't work\n");
-       else
+       } else {
+               rc->uwbd.task = task;
                rc->uwbd.pid = rc->uwbd.task->pid;
+       }
 }
 
 /* Stop the UWB daemon and free any unprocessed events */
 void uwbd_stop(struct uwb_rc *rc)
 {
-       kthread_stop(rc->uwbd.task);
+       if (rc->uwbd.task)
+               kthread_stop(rc->uwbd.task);
        uwbd_flush(rc);
 }