Commit 4a567394 authored by figo.zhang's avatar figo.zhang Committed by Mauro Carvalho Chehab

V4L/DVB (11852): saa7134-video.c: poll method lose race condition

saa7134-video.c: poll method lose race condition
Signed-off-by: default avatarFigo Zhang <figo.zhang@kolorific.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 7d853532
...@@ -1423,11 +1423,13 @@ video_poll(struct file *file, struct poll_table_struct *wait) ...@@ -1423,11 +1423,13 @@ video_poll(struct file *file, struct poll_table_struct *wait)
{ {
struct saa7134_fh *fh = file->private_data; struct saa7134_fh *fh = file->private_data;
struct videobuf_buffer *buf = NULL; struct videobuf_buffer *buf = NULL;
unsigned int rc = 0;
if (V4L2_BUF_TYPE_VBI_CAPTURE == fh->type) if (V4L2_BUF_TYPE_VBI_CAPTURE == fh->type)
return videobuf_poll_stream(file, &fh->vbi, wait); return videobuf_poll_stream(file, &fh->vbi, wait);
if (res_check(fh,RESOURCE_VIDEO)) { if (res_check(fh,RESOURCE_VIDEO)) {
mutex_lock(&fh->cap.vb_lock);
if (!list_empty(&fh->cap.stream)) if (!list_empty(&fh->cap.stream))
buf = list_entry(fh->cap.stream.next, struct videobuf_buffer, stream); buf = list_entry(fh->cap.stream.next, struct videobuf_buffer, stream);
} else { } else {
...@@ -1446,13 +1448,14 @@ video_poll(struct file *file, struct poll_table_struct *wait) ...@@ -1446,13 +1448,14 @@ video_poll(struct file *file, struct poll_table_struct *wait)
} }
if (!buf) if (!buf)
return POLLERR; goto err;
poll_wait(file, &buf->done, wait); poll_wait(file, &buf->done, wait);
if (buf->state == VIDEOBUF_DONE || if (buf->state == VIDEOBUF_DONE ||
buf->state == VIDEOBUF_ERROR) buf->state == VIDEOBUF_ERROR)
return POLLIN|POLLRDNORM; rc = POLLIN|POLLRDNORM;
return 0; mutex_unlock(&fh->cap.vb_lock);
return rc;
err: err:
mutex_unlock(&fh->cap.vb_lock); mutex_unlock(&fh->cap.vb_lock);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment