Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1731695 > unrolled thread
| Started by | Andrey Konovalov <andreyknvl@google.com> |
|---|---|
| First post | 2017-09-13 18:10 +0200 |
| Last post | 2017-09-14 14:40 +0200 |
| Articles | 3 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH v2] uwb: properly check kthread_run return value Andrey Konovalov <andreyknvl@google.com> - 2017-09-13 18:10 +0200
Re: [PATCH v2] uwb: properly check kthread_run return value Dmitry Vyukov <dvyukov@google.com> - 2017-09-13 19:00 +0200
Re: [PATCH v2] uwb: properly check kthread_run return value Andrey Konovalov <andreyknvl@google.com> - 2017-09-14 14:40 +0200
| From | Andrey Konovalov <andreyknvl@google.com> |
|---|---|
| Date | 2017-09-13 18:10 +0200 |
| Subject | [PATCH v2] uwb: properly check kthread_run return value |
| Message-ID | <upioF-1as-1@gated-at.bofh.it> |
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
[toc] | [next] | [standalone]
| From | Dmitry Vyukov <dvyukov@google.com> |
|---|---|
| Date | 2017-09-13 19:00 +0200 |
| Message-ID | <upjb4-1qQ-17@gated-at.bofh.it> |
| In reply to | #1731695 |
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.
> uwbd_flush(rc);
> }
>
> --
> 2.14.1.581.gf28d330327-goog
>
[toc] | [prev] | [next] | [standalone]
| From | Andrey Konovalov <andreyknvl@google.com> |
|---|---|
| Date | 2017-09-14 14:40 +0200 |
| Message-ID | <upBAZ-52v-5@gated-at.bofh.it> |
| In reply to | #1731718 |
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
>>
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web