| From 4fbb481a565ad61ed101d6a849ff78efe1ef688c Mon Sep 17 00:00:00 2001 |
| From: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com> |
| Date: Wed, 8 Jan 2014 05:01:33 -0300 |
| Subject: [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 <ricardo.ribalda@gmail.com> |
| Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> |
| Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com> |
| (cherry picked from commit 249f5a58bc844506fef2e9d5d55a88fbc708c5fa) |
| Signed-off-by: Simon Horman <horms+renesas@verge.net.au> |
| --- |
| drivers/media/v4l2-core/videobuf2-core.c | 5 +++++ |
| 1 file changed, 5 insertions(+) |
| |
| --- a/drivers/media/v4l2-core/videobuf2-core.c |
| +++ b/drivers/media/v4l2-core/videobuf2-core.c |
| @@ -1784,6 +1784,11 @@ static int vb2_internal_streamon(struct |
| 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. |