* [PATCH] m5602: correctly check failed thread creation
@ 2015-10-19 15:24 Insu Yun
2015-10-20 8:16 ` Hans de Goede
0 siblings, 1 reply; 3+ messages in thread
From: Insu Yun @ 2015-10-19 15:24 UTC (permalink / raw)
To: erik.andren, hdegoede, mchehab, linux-media, linux-kernel
Cc: taesoo, yeongjin.jang, insu, changwoo, Insu Yun
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] m5602: correctly check failed thread creation
2015-10-19 15:24 [PATCH] m5602: correctly check failed thread creation Insu Yun
@ 2015-10-20 8:16 ` Hans de Goede
0 siblings, 0 replies; 3+ messages in thread
From: Hans de Goede @ 2015-10-20 8:16 UTC (permalink / raw)
To: Insu Yun, erik.andren, mchehab, linux-media, linux-kernel
Cc: taesoo, yeongjin.jang, insu, changwoo
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] m5602: correctly check failed thread creation
@ 2015-11-17 20:36 Insu Yun
0 siblings, 0 replies; 3+ messages in thread
From: Insu Yun @ 2015-11-17 20:36 UTC (permalink / raw)
To: erik.andren, hdegoede, mchehab, linux-media, linux-kernel
Cc: taesoo, yeongjin.jang, insu, changwoo, Insu Yun
Signed-off-by: Insu Yun <wuninsu@gmail.com>
---
drivers/media/usb/gspca/m5602/m5602_s5k83a.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/media/usb/gspca/m5602/m5602_s5k83a.c b/drivers/media/usb/gspca/m5602/m5602_s5k83a.c
index bf6b215..84b2961 100644
--- a/drivers/media/usb/gspca/m5602/m5602_s5k83a.c
+++ b/drivers/media/usb/gspca/m5602/m5602_s5k83a.c
@@ -221,6 +221,9 @@ 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))
+ return PTR_ERR(sd->rotation_thread);
+
wake_up_process(sd->rotation_thread);
/* Preinit the sensor */
--
1.9.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-11-17 20:36 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-19 15:24 [PATCH] m5602: correctly check failed thread creation Insu Yun
2015-10-20 8:16 ` Hans de Goede
2015-11-17 20:36 Insu Yun
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).