The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Andrey Konovalov <andreyknvl@google.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Johan Hovold <johan@kernel.org>,
	"Gustavo A . R . Silva" <garsilva@embeddedor.com>,
	Arvind Yadav <arvind.yadav.cs@gmail.com>,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Dmitry Vyukov <dvyukov@google.com>,
	Kostya Serebryany <kcc@google.com>,
	Andrey Konovalov <andreyknvl@google.com>
Subject: [PATCH v2] uwb: properly check kthread_run return value
Date: Wed, 13 Sep 2017 18:06:58 +0200	[thread overview]
Message-ID: <20170913160658.18131-1-andreyknvl@google.com> (raw)

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>
---
 drivers/uwb/uwbd.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/uwb/uwbd.c b/drivers/uwb/uwbd.c
index 01c20a260a8b..2a3cc48d837c 100644
--- a/drivers/uwb/uwbd.c
+++ b/drivers/uwb/uwbd.c
@@ -303,7 +303,7 @@ static int uwbd(void *param)
 void uwbd_start(struct uwb_rc *rc)
 {
 	rc->uwbd.task = kthread_run(uwbd, rc, "uwbd");
-	if (rc->uwbd.task == NULL)
+	if (IS_ERR(rc->uwbd.task))
 		printk(KERN_ERR "UWB: Cannot start management daemon; "
 		       "UWB won't work\n");
 	else
@@ -313,7 +313,8 @@ void uwbd_start(struct uwb_rc *rc)
 /* Stop the UWB daemon and free any unprocessed events */
 void uwbd_stop(struct uwb_rc *rc)
 {
-	kthread_stop(rc->uwbd.task);
+	if (!IS_ERR(rc->uwbd.task))
+		kthread_stop(rc->uwbd.task);
 	uwbd_flush(rc);
 }
 
-- 
2.14.1.581.gf28d330327-goog

             reply	other threads:[~2017-09-13 16:07 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-13 16:06 Andrey Konovalov [this message]
2017-09-13 16:53 ` [PATCH v2] uwb: properly check kthread_run return value Dmitry Vyukov
2017-09-14 12:31   ` Andrey Konovalov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170913160658.18131-1-andreyknvl@google.com \
    --to=andreyknvl@google.com \
    --cc=arvind.yadav.cs@gmail.com \
    --cc=dvyukov@google.com \
    --cc=garsilva@embeddedor.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=johan@kernel.org \
    --cc=kcc@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox