linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrey Konovalov <andreyknvl@google.com>
To: Dmitry Vyukov <dvyukov@google.com>
Cc: 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>,
	USB list <linux-usb@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Kostya Serebryany <kcc@google.com>
Subject: Re: [PATCH v2] uwb: properly check kthread_run return value
Date: Thu, 14 Sep 2017 14:31:25 +0200	[thread overview]
Message-ID: <CAAeHK+xN+xFxjR+c6RRAau1h2jpouCsu6nbr4S0Rf_sYDhJg=g@mail.gmail.com> (raw)
In-Reply-To: <CACT4Y+YC-6L8XPXTpdRYccap+nS-oRvcV+fc13+X_Q8Q1Lgfzw@mail.gmail.com>

On Wed, Sep 13, 2017 at 6:53 PM, Dmitry Vyukov <dvyukov@google.com> wrote:
> On Wed, Sep 13, 2017 at 6:06 PM, Andrey Konovalov <andreyknvl@google.com> wrote:
>> 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);
>
> It looks weird to assign an error to rc->uwbd.task and leave it there.
> I think it's better to not assign errors to rc->uwbd.task, i.e. it's
> either a valid task or NULL.

Sent v3.

>
>>         uwbd_flush(rc);
>>  }
>>
>> --
>> 2.14.1.581.gf28d330327-goog
>>

      reply	other threads:[~2017-09-14 12:31 UTC|newest]

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

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='CAAeHK+xN+xFxjR+c6RRAau1h2jpouCsu6nbr4S0Rf_sYDhJg=g@mail.gmail.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;
as well as URLs for NNTP newsgroup(s).