From: Hans Verkuil <hans.verk...@cisco.com>

The format passed to VIDIOC_CREATE_BUFS is completely unchecked at
the moment. So pass it to VIDIOC_TRY_FMT first.

Signed-off-by: Hans Verkuil <hans.verk...@cisco.com>
---
 drivers/media/v4l2-core/v4l2-ioctl.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c 
b/drivers/media/v4l2-core/v4l2-ioctl.c
index 707aef7..7b9d59e 100644
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -1443,9 +1443,15 @@ static int v4l_dqbuf(const struct v4l2_ioctl_ops *ops,
 static int v4l_create_bufs(const struct v4l2_ioctl_ops *ops,
                                struct file *file, void *fh, void *arg)
 {
+       struct video_device *vfd = video_devdata(file);
        struct v4l2_create_buffers *create = arg;
        int ret = check_fmt(file, create->format.type);
 
+       if (ret)
+               return ret;
+
+       if (!WARN_ON(!is_valid_ioctl(vfd, VIDIOC_TRY_FMT)))
+               ret = v4l_try_fmt(ops, file, fh, &create->format);
        return ret ? ret : ops->vidioc_create_bufs(file, fh, create);
 }
 
-- 
1.8.5.2

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to