public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH  v2]saa7134-video.c: poll method lose race condition for capture video
@ 2009-05-19  2:14 figo.zhang
  0 siblings, 0 replies; only message in thread
From: figo.zhang @ 2009-05-19  2:14 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: linux-media, figo1802, kraxel, Hans Verkuil,
	Oldřich Jedlička

saa7134-video.c: poll method lose race condition for capture video.

In v2, when buf == NULL, it will goto err, return  "PULLERR"
immediately.

Signed-off-by: Figo.zhang <figo.zhang@kolorific.com>
---  
drivers/media/video/saa7134/saa7134-video.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/media/video/saa7134/saa7134-video.c b/drivers/media/video/saa7134/saa7134-video.c
index 493cad9..b1c2dbd 100644
--- a/drivers/media/video/saa7134/saa7134-video.c
+++ b/drivers/media/video/saa7134/saa7134-video.c
@@ -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);



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2009-05-19  2:14 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-19  2:14 [PATCH v2]saa7134-video.c: poll method lose race condition for capture video figo.zhang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox