]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/3.18.75/uwb-properly-check-kthread_run-return-value.patch
Linux 3.18.75
[thirdparty/kernel/stable-queue.git] / releases / 3.18.75 / uwb-properly-check-kthread_run-return-value.patch
CommitLineData
35b2d84a
GKH
1From bbf26183b7a6236ba602f4d6a2f7cade35bba043 Mon Sep 17 00:00:00 2001
2From: Andrey Konovalov <andreyknvl@google.com>
3Date: Thu, 14 Sep 2017 14:30:55 +0200
4Subject: uwb: properly check kthread_run return value
5
6From: Andrey Konovalov <andreyknvl@google.com>
7
8commit bbf26183b7a6236ba602f4d6a2f7cade35bba043 upstream.
9
10uwbd_start() calls kthread_run() and checks that the return value is
11not NULL. But the return value is not NULL in case kthread_run() fails,
12it takes the form of ERR_PTR(-EINTR).
13
14Use IS_ERR() instead.
15
16Also add a check to uwbd_stop().
17
18Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
19Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
20
21---
22 drivers/uwb/uwbd.c | 12 ++++++++----
23 1 file changed, 8 insertions(+), 4 deletions(-)
24
25--- a/drivers/uwb/uwbd.c
26+++ b/drivers/uwb/uwbd.c
27@@ -303,18 +303,22 @@ static int uwbd(void *param)
28 /** Start the UWB daemon */
29 void uwbd_start(struct uwb_rc *rc)
30 {
31- rc->uwbd.task = kthread_run(uwbd, rc, "uwbd");
32- if (rc->uwbd.task == NULL)
33+ struct task_struct *task = kthread_run(uwbd, rc, "uwbd");
34+ if (IS_ERR(task)) {
35+ rc->uwbd.task = NULL;
36 printk(KERN_ERR "UWB: Cannot start management daemon; "
37 "UWB won't work\n");
38- else
39+ } else {
40+ rc->uwbd.task = task;
41 rc->uwbd.pid = rc->uwbd.task->pid;
42+ }
43 }
44
45 /* Stop the UWB daemon and free any unprocessed events */
46 void uwbd_stop(struct uwb_rc *rc)
47 {
48- kthread_stop(rc->uwbd.task);
49+ if (rc->uwbd.task)
50+ kthread_stop(rc->uwbd.task);
51 uwbd_flush(rc);
52 }
53