diff options
author | Andy Walls <awalls@radix.net> | 2008-08-23 15:42:29 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2008-10-12 07:36:53 -0400 |
commit | d3c5e7075508a6874d1a53d0a409b0bbbe3a9fbe (patch) | |
tree | a9e6884ac71641938abc1866e5d81f607bd5f907 /drivers/media/video/cx18/cx18-ioctl.c | |
parent | b04bce476c57ac844962462ee4c813c44fa942cf (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.c | 17 |
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 5325c7aacaf3..84507a39f2b8 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, | |||
622 | { | 622 | { |
623 | struct cx18_open_id *id = fh; | 623 | struct cx18_open_id *id = fh; |
624 | struct cx18 *cx = id->cx; | 624 | struct cx18 *cx = id->cx; |
625 | u32 h; | ||
625 | 626 | ||
626 | switch (enc->cmd) { | 627 | switch (enc->cmd) { |
627 | case V4L2_ENC_CMD_START: | 628 | case V4L2_ENC_CMD_START: |
@@ -643,8 +644,14 @@ static int cx18_encoder_cmd(struct file *file, void *fh, | |||
643 | return -EPERM; | 644 | return -EPERM; |
644 | if (test_and_set_bit(CX18_F_I_ENC_PAUSED, &cx->i_flags)) | 645 | if (test_and_set_bit(CX18_F_I_ENC_PAUSED, &cx->i_flags)) |
645 | return 0; | 646 | return 0; |
647 | h = cx18_find_handle(cx); | ||
648 | if (h == CX18_INVALID_TASK_HANDLE) { | ||
649 | CX18_ERR("Can't find valid task handle for " | ||
650 | "V4L2_ENC_CMD_PAUSE\n"); | ||
651 | return -EBADFD; | ||
652 | } | ||
646 | cx18_mute(cx); | 653 | cx18_mute(cx); |
647 | cx18_vapi(cx, CX18_CPU_CAPTURE_PAUSE, 1, cx18_find_handle(cx)); | 654 | cx18_vapi(cx, CX18_CPU_CAPTURE_PAUSE, 1, h); |
648 | break; | 655 | break; |
649 | 656 | ||
650 | case V4L2_ENC_CMD_RESUME: | 657 | case V4L2_ENC_CMD_RESUME: |
@@ -654,7 +661,13 @@ static int cx18_encoder_cmd(struct file *file, void *fh, | |||
654 | return -EPERM; | 661 | return -EPERM; |
655 | if (!test_and_clear_bit(CX18_F_I_ENC_PAUSED, &cx->i_flags)) | 662 | if (!test_and_clear_bit(CX18_F_I_ENC_PAUSED, &cx->i_flags)) |
656 | return 0; | 663 | return 0; |
657 | cx18_vapi(cx, CX18_CPU_CAPTURE_RESUME, 1, cx18_find_handle(cx)); | 664 | h = cx18_find_handle(cx); |
665 | if (h == CX18_INVALID_TASK_HANDLE) { | ||
666 | CX18_ERR("Can't find valid task handle for " | ||
667 | "V4L2_ENC_CMD_RESUME\n"); | ||
668 | return -EBADFD; | ||
669 | } | ||
670 | cx18_vapi(cx, CX18_CPU_CAPTURE_RESUME, 1, h); | ||
658 | cx18_unmute(cx); | 671 | cx18_unmute(cx); |
659 | break; | 672 | break; |
660 | 673 | ||