If the vb2_queue for which the request is validated only supports read-only requests, then check if non-buffer objects are in the request and return -EINVAL if that is the case. Signed-off-by: Hans Verkuil <hverkuil-cisco@xxxxxxxxx> --- .../media/common/videobuf2/videobuf2-v4l2.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/drivers/media/common/videobuf2/videobuf2-v4l2.c b/drivers/media/common/videobuf2/videobuf2-v4l2.c index c63ee7bc3331..93897c3f32e9 100644 --- a/drivers/media/common/videobuf2/videobuf2-v4l2.c +++ b/drivers/media/common/videobuf2/videobuf2-v4l2.c @@ -1278,12 +1278,20 @@ EXPORT_SYMBOL_GPL(vb2_ops_wait_finish); int vb2_request_validate(struct media_request *req) { struct media_request_object *obj; + struct vb2_queue *q = NULL; + bool buffers_only = true; int ret = 0; - if (!vb2_request_buffer_cnt(req)) - return -ENOENT; - list_for_each_entry(obj, &req->objects, list) { + if (!vb2_request_object_is_buffer(obj)) { + buffers_only = false; + } else if (!q) { + struct vb2_buffer *vb; + + vb = container_of(obj, struct vb2_buffer, req_obj); + q = vb->vb2_queue; + } + if (!obj->ops->prepare) continue; @@ -1292,6 +1300,11 @@ int vb2_request_validate(struct media_request *req) break; } + if (!q) + ret = -ENOENT; + else if (q->supports_ro_requests && !buffers_only) + ret = -EINVAL; + if (ret) { list_for_each_entry_continue_reverse(obj, &req->objects, list) if (obj->ops->unprepare) -- 2.30.2