diff mbox

[RFCv1,9/9] v4l2-ioctl: check CREATE_BUFS format via TRY_FMT.

Message ID 1391093491-23077-10-git-send-email-hverkuil@xs4all.nl (mailing list archive)
State New, archived
Headers show

Commit Message

Hans Verkuil Jan. 30, 2014, 2:51 p.m. UTC
From: Hans Verkuil <hans.verkuil@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.verkuil@cisco.com>
---
 drivers/media/v4l2-core/v4l2-ioctl.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Hans Verkuil Feb. 4, 2014, 8:54 a.m. UTC | #1
On 01/30/2014 03:51 PM, Hans Verkuil wrote:
> From: Hans Verkuil <hans.verkuil@cisco.com>
> 
> The format passed to VIDIOC_CREATE_BUFS is completely unchecked at
> the moment. So pass it to VIDIOC_TRY_FMT first.

Don't bother reviewing this. I'm going to change this anyway.

Regards,

	Hans

> 
> Signed-off-by: Hans Verkuil <hans.verkuil@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);
>  }
>  
> 

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

Patch

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);
 }