]> Pileus Git - ~andy/linux/commitdiff
V4L/DVB (11852): saa7134-video.c: poll method lose race condition
authorfigo.zhang <figo.zhang@kolorific.com>
Mon, 18 May 2009 02:13:13 +0000 (23:13 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Tue, 16 Jun 2009 21:21:12 +0000 (18:21 -0300)
saa7134-video.c: poll method lose race condition

Signed-off-by: Figo Zhang <figo.zhang@kolorific.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/video/saa7134/saa7134-video.c

index 493cad941460e0fc32725332d907e19959c474e6..ceae3c88f93e310e23b18c4b5708197b5b47da4b 100644 (file)
@@ -1423,11 +1423,13 @@ video_poll(struct file *file, struct poll_table_struct *wait)
 {
        struct saa7134_fh *fh = file->private_data;
        struct videobuf_buffer *buf = NULL;
+       unsigned int rc = 0;
 
        if (V4L2_BUF_TYPE_VBI_CAPTURE == fh->type)
                return videobuf_poll_stream(file, &fh->vbi, wait);
 
        if (res_check(fh,RESOURCE_VIDEO)) {
+               mutex_lock(&fh->cap.vb_lock);
                if (!list_empty(&fh->cap.stream))
                        buf = list_entry(fh->cap.stream.next, struct videobuf_buffer, stream);
        } else {
@@ -1446,13 +1448,14 @@ video_poll(struct file *file, struct poll_table_struct *wait)
        }
 
        if (!buf)
-               return POLLERR;
+               goto err;
 
        poll_wait(file, &buf->done, wait);
        if (buf->state == VIDEOBUF_DONE ||
            buf->state == VIDEOBUF_ERROR)
-               return POLLIN|POLLRDNORM;
-       return 0;
+               rc = POLLIN|POLLRDNORM;
+       mutex_unlock(&fh->cap.vb_lock);
+       return rc;
 
 err:
        mutex_unlock(&fh->cap.vb_lock);