public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] vb2: Check if there are buffers before streamon
@ 2014-01-08  8:01 Ricardo Ribalda Delgado
  2014-01-08  9:25 ` Marek Szyprowski
  2014-04-01 11:07 ` Andrzej Hajda
  0 siblings, 2 replies; 3+ messages in thread
From: Ricardo Ribalda Delgado @ 2014-01-08  8:01 UTC (permalink / raw)
  To: Marek Szyprowski, Hans Verkuil, Pawel Osciak, Kyungmin Park,
	Mauro Carvalho Chehab, open list:VIDEOBUF2 FRAMEWORK, open list
  Cc: Ricardo Ribalda Delgado

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 <ricardo.ribalda@gmail.com>
---
v2: Comment by Marek Szyprowski:
Reword error message

v3: Comment by Marek Szyprowski:
Actualy do the reword :)

 drivers/media/v4l2-core/videobuf2-core.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c
index 098df28..6409e0a 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -1776,6 +1776,11 @@ static int vb2_internal_streamon(struct vb2_queue *q, enum v4l2_buf_type type)
 		return 0;
 	}
 
+	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.
-- 
1.8.5.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-04-01 11:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-08  8:01 [PATCH v3] vb2: Check if there are buffers before streamon Ricardo Ribalda Delgado
2014-01-08  9:25 ` Marek Szyprowski
2014-04-01 11:07 ` Andrzej Hajda

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