]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
V4L/DVB (6276): V4L: videobuf-core.c lock before streaming check
authorBrandon Philips <bphilips@suse.de>
Thu, 27 Sep 2007 23:55:28 +0000 (20:55 -0300)
committerMauro Carvalho Chehab <mchehab@infradead.org>
Wed, 10 Oct 2007 03:03:05 +0000 (00:03 -0300)
The reading/streaming fields are used for mutual exclusion of the queue and
should be protected by the queue lock.

Signed-off-by: Brandon Philips <bphilips@suse.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
http://thread.gmane.org/gmane.comp.video.video4linux/34978/focus=34981
Reviewed-by: Ricardo Cerqueira <v4l@cerqueira.org>
drivers/media/video/videobuf-core.c

index a27e114cacef94dc2526d628e49b9236fa564cf4..ca67f80184bdfb69fd9e44a6e420036793dd58c4 100644 (file)
@@ -289,16 +289,18 @@ int videobuf_reqbufs(struct videobuf_queue *q,
                return -EINVAL;
        }
 
+       mutex_lock(&q->lock);
        if (q->streaming) {
                dprintk(1,"reqbufs: streaming already exists\n");
-               return -EBUSY;
+               retval = -EBUSY;
+               goto done;
        }
        if (!list_empty(&q->stream)) {
                dprintk(1,"reqbufs: stream running\n");
-               return -EBUSY;
+               retval = -EBUSY;
+               goto done;
        }
 
-       mutex_lock(&q->lock);
        count = req->count;
        if (count > VIDEO_MAX_FRAME)
                count = VIDEO_MAX_FRAME;