From: Ricardo Ribalda Delgado Date: Wed, 8 Jan 2014 08:01:33 +0000 (-0300) Subject: upstream: [media] vb2: Check if there are buffers before streamon X-Git-Tag: submit/tizen/20141121.110247~1390 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=83955cbd129f9433399dbc826f4fd862d5d2818f;p=platform%2Fkernel%2Flinux-3.10.git upstream: [media] vb2: Check if there are buffers before streamon This patch adds a test preventing streamon() if there is no buffer ready. Without this patch, a user could call streamon() before preparing any buffer. This leads to a situation where if he calls close() before calling streamoff() the device is kept streaming. Signed-off-by: Ricardo Ribalda Delgado Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c index c916f3d..5ffa285 100644 --- a/drivers/media/v4l2-core/videobuf2-core.c +++ b/drivers/media/v4l2-core/videobuf2-core.c @@ -1815,6 +1815,11 @@ static int vb2_internal_streamon(struct vb2_queue *q, enum v4l2_buf_type type) return -EINVAL; } + if (!q->num_buffers) { + dprintk(1, "streamon: no buffers have been allocated\n"); + return -EINVAL; + } + /* * If any buffers were queued before streamon, * we can now pass them to driver for processing.