diff options
author | Figo.zhang <figo1802@gmail.com> | 2009-06-16 12:31:29 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-06-16 18:14:44 -0400 |
commit | 9fd6418a6a7655b69cfa0ae27a3639a6d0b2924f (patch) | |
tree | 3b3754a6518f7cefb130b314199733daaf831d2b /drivers/media/video/cx23885/cx23885-video.c | |
parent | 1c905a4522a3913cf321365c5bb62eb2f70d55d9 (diff) |
V4L/DVB (12004): poll method lose race condition
bttv-driver.c,cx23885-video.c,cx88-video.c: poll method lose race condition for capture video.
Signed-off-by: Figo.zhang <figo1802@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/cx23885/cx23885-video.c')
-rw-r--r-- | drivers/media/video/cx23885/cx23885-video.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/drivers/media/video/cx23885/cx23885-video.c b/drivers/media/video/cx23885/cx23885-video.c index 68068c6d0987..66bbd2e71105 100644 --- a/drivers/media/video/cx23885/cx23885-video.c +++ b/drivers/media/video/cx23885/cx23885-video.c | |||
@@ -796,6 +796,7 @@ static unsigned int video_poll(struct file *file, | |||
796 | { | 796 | { |
797 | struct cx23885_fh *fh = file->private_data; | 797 | struct cx23885_fh *fh = file->private_data; |
798 | struct cx23885_buffer *buf; | 798 | struct cx23885_buffer *buf; |
799 | unsigned int rc = POLLERR; | ||
799 | 800 | ||
800 | if (V4L2_BUF_TYPE_VBI_CAPTURE == fh->type) { | 801 | if (V4L2_BUF_TYPE_VBI_CAPTURE == fh->type) { |
801 | if (!res_get(fh->dev, fh, RESOURCE_VBI)) | 802 | if (!res_get(fh->dev, fh, RESOURCE_VBI)) |
@@ -803,23 +804,28 @@ static unsigned int video_poll(struct file *file, | |||
803 | return videobuf_poll_stream(file, &fh->vbiq, wait); | 804 | return videobuf_poll_stream(file, &fh->vbiq, wait); |
804 | } | 805 | } |
805 | 806 | ||
807 | mutex_lock(&fh->vidq.vb_lock); | ||
806 | if (res_check(fh, RESOURCE_VIDEO)) { | 808 | if (res_check(fh, RESOURCE_VIDEO)) { |
807 | /* streaming capture */ | 809 | /* streaming capture */ |
808 | if (list_empty(&fh->vidq.stream)) | 810 | if (list_empty(&fh->vidq.stream)) |
809 | return POLLERR; | 811 | goto done; |
810 | buf = list_entry(fh->vidq.stream.next, | 812 | buf = list_entry(fh->vidq.stream.next, |
811 | struct cx23885_buffer, vb.stream); | 813 | struct cx23885_buffer, vb.stream); |
812 | } else { | 814 | } else { |
813 | /* read() capture */ | 815 | /* read() capture */ |
814 | buf = (struct cx23885_buffer *)fh->vidq.read_buf; | 816 | buf = (struct cx23885_buffer *)fh->vidq.read_buf; |
815 | if (NULL == buf) | 817 | if (NULL == buf) |
816 | return POLLERR; | 818 | goto done; |
817 | } | 819 | } |
818 | poll_wait(file, &buf->vb.done, wait); | 820 | poll_wait(file, &buf->vb.done, wait); |
819 | if (buf->vb.state == VIDEOBUF_DONE || | 821 | if (buf->vb.state == VIDEOBUF_DONE || |
820 | buf->vb.state == VIDEOBUF_ERROR) | 822 | buf->vb.state == VIDEOBUF_ERROR) |
821 | return POLLIN|POLLRDNORM; | 823 | rc = POLLIN|POLLRDNORM; |
822 | return 0; | 824 | else |
825 | rc = 0; | ||
826 | done: | ||
827 | mutex_unlock(&fh->vidq.vb_lock); | ||
828 | return rc; | ||
823 | } | 829 | } |
824 | 830 | ||
825 | static int video_release(struct file *file) | 831 | static int video_release(struct file *file) |