diff options
author | Hans Verkuil <hverkuil@xs4all.nl> | 2019-04-01 15:41:58 +0300 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab+samsung@kernel.org> | 2019-04-22 18:43:00 +0300 |
commit | 1f7f11e8ca15366e6c1e62e4d4dc5d1ecb3b2eb4 (patch) | |
tree | a39a33b9441e6b7905120109a19947480a305bc9 /drivers/media/common | |
parent | 411a414b26aa107ddbbd6995e464f6cc18a1aa8c (diff) | |
download | linux-1f7f11e8ca15366e6c1e62e4d4dc5d1ecb3b2eb4.tar.xz |
media: videobuf2-v4l2.c: move up STATE_DEQUEUED check
If a buffer is queued to a request, followed by an attempt to queue
the same buffer again, then the second qbuf returns an error since
the buffer is not in the DEQUEUED state anymore.
However, before it gets to that check it executes the code under the
'if (!vb->prepared)' condition. This clears previously set data needed
for request handling, and now querybuf will no longer report that this
buffer is part of a request.
Move the state check to before the 'if' and make sure to only do the
state check when called from QBUF and if V4L2_BUF_FLAG_REQUEST_FD is
set.
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Diffstat (limited to 'drivers/media/common')
-rw-r--r-- | drivers/media/common/videobuf2/videobuf2-v4l2.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/drivers/media/common/videobuf2/videobuf2-v4l2.c b/drivers/media/common/videobuf2/videobuf2-v4l2.c index 1c3147275785..fb9ac7696fc6 100644 --- a/drivers/media/common/videobuf2/videobuf2-v4l2.c +++ b/drivers/media/common/videobuf2/videobuf2-v4l2.c @@ -368,6 +368,12 @@ static int vb2_queue_or_prepare_buf(struct vb2_queue *q, struct media_device *md if (ret) return ret; + if (!is_prepare && (b->flags & V4L2_BUF_FLAG_REQUEST_FD) && + vb->state != VB2_BUF_STATE_DEQUEUED) { + dprintk(1, "%s: buffer is not in dequeued state\n", opname); + return -EINVAL; + } + if (!vb->prepared) { /* Copy relevant information provided by the userspace */ memset(vbuf->planes, 0, @@ -423,11 +429,6 @@ static int vb2_queue_or_prepare_buf(struct vb2_queue *q, struct media_device *md !q->ops->buf_out_validate)) return -EINVAL; - if (vb->state != VB2_BUF_STATE_DEQUEUED) { - dprintk(1, "%s: buffer is not in dequeued state\n", opname); - return -EINVAL; - } - if (b->request_fd < 0) { dprintk(1, "%s: request_fd < 0\n", opname); return -EINVAL; |