[PATCH] m5602: correctly check failed thread creation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Since thread creation can be failed, check return value of
kthread_create and handle an error.

Signed-off-by: Insu Yun <wuninsu@xxxxxxxxx>
---
 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-media" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux