Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1250840 > unrolled thread
| Started by | Insu Yun <wuninsu@gmail.com> |
|---|---|
| First post | 2015-10-19 17:30 +0200 |
| Last post | 2015-10-20 10:20 +0200 |
| Articles | 2 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH] m5602: correctly check failed thread creation Insu Yun <wuninsu@gmail.com> - 2015-10-19 17:30 +0200
Re: [PATCH] m5602: correctly check failed thread creation Hans de Goede <hdegoede@redhat.com> - 2015-10-20 10:20 +0200
| From | Insu Yun <wuninsu@gmail.com> |
|---|---|
| Date | 2015-10-19 17:30 +0200 |
| Subject | [PATCH] m5602: correctly check failed thread creation |
| Message-ID | <qlkxR-8qb-41@gated-at.bofh.it> |
Since thread creation can be failed, check return value of
kthread_create and handle an error.
Signed-off-by: Insu Yun <wuninsu@gmail.com>
---
drivers/media/usb/gspca/m5602/m5602_s5k83a.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/media/usb/gspca/m5602/m5602_s5k83a.c b/drivers/media/usb/gspca/m5602/m5602_s5k83a.c
index bf6b215..76b40d1 100644
--- a/drivers/media/usb/gspca/m5602/m5602_s5k83a.c
+++ b/drivers/media/usb/gspca/m5602/m5602_s5k83a.c
@@ -221,6 +221,10 @@ int s5k83a_start(struct sd *sd)
to assume that there is no better way of accomplishing this */
sd->rotation_thread = kthread_create(rotation_thread_function,
sd, "rotation thread");
+ if (IS_ERR(sd->rotation_thread)) {
+ err = PTR_ERR(sd->rotation_thread);
+ goto fail;
+ }
wake_up_process(sd->rotation_thread);
/* Preinit the sensor */
@@ -234,9 +238,11 @@ int s5k83a_start(struct sd *sd)
data[0]);
}
if (err < 0)
- return err;
+ goto fail;
return s5k83a_set_led_indication(sd, 1);
+fail:
+ return err;
}
int s5k83a_stop(struct sd *sd)
--
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | Hans de Goede <hdegoede@redhat.com> |
|---|---|
| Date | 2015-10-20 10:20 +0200 |
| Message-ID | <qlAjf-6os-7@gated-at.bofh.it> |
| In reply to | #1250840 |
Hi,
On 19-10-15 17:24, Insu Yun wrote:
> Since thread creation can be failed, check return value of
> kthread_create and handle an error.
>
> Signed-off-by: Insu Yun <wuninsu@gmail.com>
> ---
> drivers/media/usb/gspca/m5602/m5602_s5k83a.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/media/usb/gspca/m5602/m5602_s5k83a.c b/drivers/media/usb/gspca/m5602/m5602_s5k83a.c
> index bf6b215..76b40d1 100644
> --- a/drivers/media/usb/gspca/m5602/m5602_s5k83a.c
> +++ b/drivers/media/usb/gspca/m5602/m5602_s5k83a.c
> @@ -221,6 +221,10 @@ int s5k83a_start(struct sd *sd)
> to assume that there is no better way of accomplishing this */
> sd->rotation_thread = kthread_create(rotation_thread_function,
> sd, "rotation thread");
> + if (IS_ERR(sd->rotation_thread)) {
> + err = PTR_ERR(sd->rotation_thread);
> + goto fail;
> + }
There is no need to use a goto here you can simply directly return
the error.
> wake_up_process(sd->rotation_thread);
>
> /* Preinit the sensor */
> @@ -234,9 +238,11 @@ int s5k83a_start(struct sd *sd)
> data[0]);
> }
> if (err < 0)
> - return err;
> + goto fail;
No need for introducing a goto here either.
>
> return s5k83a_set_led_indication(sd, 1);
> +fail:
> + return err;
> }
>
> int s5k83a_stop(struct sd *sd)
Regards,
Hans
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web