Skip to content

Commit

Permalink
[media] vb2: Check if there are buffers before streamon
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Ricardo Ribalda Delgado authored and Mauro Carvalho Chehab committed Mar 11, 2014
1 parent c897df0 commit 249f5a5
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions drivers/media/v4l2-core/videobuf2-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1832,6 +1832,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.
Expand Down

0 comments on commit 249f5a5

Please sign in to comment.