From patchwork Mon May 18 02:13:13 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "figo.zhang" X-Patchwork-Id: 24371 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n4I2E5gE026352 for ; Mon, 18 May 2009 02:14:05 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751771AbZERCNi (ORCPT ); Sun, 17 May 2009 22:13:38 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751689AbZERCNh (ORCPT ); Sun, 17 May 2009 22:13:37 -0400 Received: from mail.kolorific.com ([61.63.28.39]:43449 "EHLO mail.kolorific.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751272AbZERCNh (ORCPT ); Sun, 17 May 2009 22:13:37 -0400 Received: from [172.16.3.3] (unknown [116.228.155.46]) by mail.kolorific.com (Postfix) with ESMTP id EE92CF5006E; Mon, 18 May 2009 10:13:19 +0800 (CST) Subject: [PATCH]saa7134-video.c: poll method lose race condition From: "figo.zhang" To: Mauro Carvalho Chehab Cc: g.liakhovetski@gmx.de, linux-media@vger.kernel.org, figo1802@126.com, kraxel@bytesex.org, Hans Verkuil Date: Mon, 18 May 2009 10:13:13 +0800 Message-Id: <1242612794.3442.19.camel@myhost> Mime-Version: 1.0 X-Mailer: Evolution 2.26.1.1 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org saa7134-video.c: poll method lose race condition Signed-off-by: Figo.zhang --- drivers/media/video/saa7134/saa7134-video.c | 9 ++++++--- 1 files changed, 6 insertions(+), 3 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/media/video/saa7134/saa7134-video.c b/drivers/media/video/saa7134/saa7134-video.c index 493cad9..95733df 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; + rc = POLLERR; 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);