All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] v4l2-subdev: without controls return -ENOTTY
@ 2018-02-02 13:05 Hans Verkuil
  2018-03-01 13:03 ` Helen Koike
  0 siblings, 1 reply; 2+ messages in thread
From: Hans Verkuil @ 2018-02-02 13:05 UTC (permalink / raw)
  To: Linux Media Mailing List; +Cc: Laurent Pinchart, Helen Koike

If the subdev did not define any controls, then return -ENOTTY if
userspace attempts to call these ioctls.

The control framework functions will return -EINVAL, not -ENOTTY if
vfh->ctrl_handler is NULL.

Several of these framework functions are also called directly from
drivers, so I don't want to change the error code there.

Found with vimc and v4l2-compliance.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c
index 43fefa73e0a3..be7a19272614 100644
--- a/drivers/media/v4l2-core/v4l2-subdev.c
+++ b/drivers/media/v4l2-core/v4l2-subdev.c
@@ -187,27 +187,43 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)

 	switch (cmd) {
 	case VIDIOC_QUERYCTRL:
+		if (!vfh->ctrl_handler)
+			return -ENOTTY;
 		return v4l2_queryctrl(vfh->ctrl_handler, arg);

 	case VIDIOC_QUERY_EXT_CTRL:
+		if (!vfh->ctrl_handler)
+			return -ENOTTY;
 		return v4l2_query_ext_ctrl(vfh->ctrl_handler, arg);

 	case VIDIOC_QUERYMENU:
+		if (!vfh->ctrl_handler)
+			return -ENOTTY;
 		return v4l2_querymenu(vfh->ctrl_handler, arg);

 	case VIDIOC_G_CTRL:
+		if (!vfh->ctrl_handler)
+			return -ENOTTY;
 		return v4l2_g_ctrl(vfh->ctrl_handler, arg);

 	case VIDIOC_S_CTRL:
+		if (!vfh->ctrl_handler)
+			return -ENOTTY;
 		return v4l2_s_ctrl(vfh, vfh->ctrl_handler, arg);

 	case VIDIOC_G_EXT_CTRLS:
+		if (!vfh->ctrl_handler)
+			return -ENOTTY;
 		return v4l2_g_ext_ctrls(vfh->ctrl_handler, arg);

 	case VIDIOC_S_EXT_CTRLS:
+		if (!vfh->ctrl_handler)
+			return -ENOTTY;
 		return v4l2_s_ext_ctrls(vfh, vfh->ctrl_handler, arg);

 	case VIDIOC_TRY_EXT_CTRLS:
+		if (!vfh->ctrl_handler)
+			return -ENOTTY;
 		return v4l2_try_ext_ctrls(vfh->ctrl_handler, arg);

 	case VIDIOC_DQEVENT:

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] v4l2-subdev: without controls return -ENOTTY
  2018-02-02 13:05 [PATCH] v4l2-subdev: without controls return -ENOTTY Hans Verkuil
@ 2018-03-01 13:03 ` Helen Koike
  0 siblings, 0 replies; 2+ messages in thread
From: Helen Koike @ 2018-03-01 13:03 UTC (permalink / raw)
  To: Hans Verkuil, Linux Media Mailing List; +Cc: Laurent Pinchart

Hi Hans

On 02/02/2018 11:05 AM, Hans Verkuil wrote:
> If the subdev did not define any controls, then return -ENOTTY if
> userspace attempts to call these ioctls.
> 
> The control framework functions will return -EINVAL, not -ENOTTY if
> vfh->ctrl_handler is NULL.
> 
> Several of these framework functions are also called directly from
> drivers, so I don't want to change the error code there.

Right, I see, thanks for the patch

> 
> Found with vimc and v4l2-compliance.
> 
> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>

Acked-by: Helen Koike <helen.koike@collabora.com>

> ---
> diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c
> index 43fefa73e0a3..be7a19272614 100644
> --- a/drivers/media/v4l2-core/v4l2-subdev.c
> +++ b/drivers/media/v4l2-core/v4l2-subdev.c
> @@ -187,27 +187,43 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)
> 
>   	switch (cmd) {
>   	case VIDIOC_QUERYCTRL:
> +		if (!vfh->ctrl_handler)
> +			return -ENOTTY;
>   		return v4l2_queryctrl(vfh->ctrl_handler, arg);
> 
>   	case VIDIOC_QUERY_EXT_CTRL:
> +		if (!vfh->ctrl_handler)
> +			return -ENOTTY;
>   		return v4l2_query_ext_ctrl(vfh->ctrl_handler, arg);
> 
>   	case VIDIOC_QUERYMENU:
> +		if (!vfh->ctrl_handler)
> +			return -ENOTTY;
>   		return v4l2_querymenu(vfh->ctrl_handler, arg);
> 
>   	case VIDIOC_G_CTRL:
> +		if (!vfh->ctrl_handler)
> +			return -ENOTTY;
>   		return v4l2_g_ctrl(vfh->ctrl_handler, arg);
> 
>   	case VIDIOC_S_CTRL:
> +		if (!vfh->ctrl_handler)
> +			return -ENOTTY;
>   		return v4l2_s_ctrl(vfh, vfh->ctrl_handler, arg);
> 
>   	case VIDIOC_G_EXT_CTRLS:
> +		if (!vfh->ctrl_handler)
> +			return -ENOTTY;
>   		return v4l2_g_ext_ctrls(vfh->ctrl_handler, arg);
> 
>   	case VIDIOC_S_EXT_CTRLS:
> +		if (!vfh->ctrl_handler)
> +			return -ENOTTY;
>   		return v4l2_s_ext_ctrls(vfh, vfh->ctrl_handler, arg);
> 
>   	case VIDIOC_TRY_EXT_CTRLS:
> +		if (!vfh->ctrl_handler)
> +			return -ENOTTY;
>   		return v4l2_try_ext_ctrls(vfh->ctrl_handler, arg);
> 
>   	case VIDIOC_DQEVENT:
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-03-01 13:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-02 13:05 [PATCH] v4l2-subdev: without controls return -ENOTTY Hans Verkuil
2018-03-01 13:03 ` Helen Koike

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.