aboutsummaryrefslogtreecommitdiff
path: root/drivers/media/video/cx18/cx18-ioctl.c
diff options
context:
space:
mode:
authorAndy Walls <awalls@radix.net>2008-08-23 16:42:29 -0300
committerMauro Carvalho Chehab <mchehab@redhat.com>2008-10-12 09:36:53 -0200
commitd3c5e7075508a6874d1a53d0a409b0bbbe3a9fbe (patch)
treea9e6884ac71641938abc1866e5d81f607bd5f907 /drivers/media/video/cx18/cx18-ioctl.c
parentb04bce476c57ac844962462ee4c813c44fa942cf (diff)
V4L/DVB (8773): cx18: Fix cx18_find_handle() and add error checking
cx18: Fix cx18_find_handle() and add error checking. cx18_find_handle() did not find a good task handle and would use the invalid task handle under common conditions. Added a define for the invalid task handle and added error checking as well. Signed-off-by: Andy Walls <awalls@radix.net> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/cx18/cx18-ioctl.c')
-rw-r--r--drivers/media/video/cx18/cx18-ioctl.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/drivers/media/video/cx18/cx18-ioctl.c b/drivers/media/video/cx18/cx18-ioctl.c
index 5325c7aacaf..84507a39f2b 100644
--- a/drivers/media/video/cx18/cx18-ioctl.c
+++ b/drivers/media/video/cx18/cx18-ioctl.c
@@ -622,6 +622,7 @@ static int cx18_encoder_cmd(struct file *file, void *fh,
{
struct cx18_open_id *id = fh;
struct cx18 *cx = id->cx;
+ u32 h;
switch (enc->cmd) {
case V4L2_ENC_CMD_START:
@@ -643,8 +644,14 @@ static int cx18_encoder_cmd(struct file *file, void *fh,
return -EPERM;
if (test_and_set_bit(CX18_F_I_ENC_PAUSED, &cx->i_flags))
return 0;
+ h = cx18_find_handle(cx);
+ if (h == CX18_INVALID_TASK_HANDLE) {
+ CX18_ERR("Can't find valid task handle for "
+ "V4L2_ENC_CMD_PAUSE\n");
+ return -EBADFD;
+ }
cx18_mute(cx);
- cx18_vapi(cx, CX18_CPU_CAPTURE_PAUSE, 1, cx18_find_handle(cx));
+ cx18_vapi(cx, CX18_CPU_CAPTURE_PAUSE, 1, h);
break;
case V4L2_ENC_CMD_RESUME:
@@ -654,7 +661,13 @@ static int cx18_encoder_cmd(struct file *file, void *fh,
return -EPERM;
if (!test_and_clear_bit(CX18_F_I_ENC_PAUSED, &cx->i_flags))
return 0;
- cx18_vapi(cx, CX18_CPU_CAPTURE_RESUME, 1, cx18_find_handle(cx));
+ h = cx18_find_handle(cx);
+ if (h == CX18_INVALID_TASK_HANDLE) {
+ CX18_ERR("Can't find valid task handle for "
+ "V4L2_ENC_CMD_RESUME\n");
+ return -EBADFD;
+ }
+ cx18_vapi(cx, CX18_CPU_CAPTURE_RESUME, 1, h);
cx18_unmute(cx);
break;