diff mbox series

[v8,13/38] media: v4l: subdev: Copy argument back to user also for S_ROUTING

Message ID 20240313072516.241106-14-sakari.ailus@linux.intel.com (mailing list archive)
State New, archived
Headers show
Series Generic line based metadata support, internal pads | expand

Commit Message

Sakari Ailus March 13, 2024, 7:24 a.m. UTC
As the user needs to know what went wrong for S_ROUTING, copy array
arguments back to the user.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
 drivers/media/v4l2-core/v4l2-ioctl.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

Comments

Julien Massot March 15, 2024, 3:50 p.m. UTC | #1
On 3/13/24 08:24, Sakari Ailus wrote:
> As the user needs to know what went wrong for S_ROUTING, copy array
> arguments back to the user.
> 
> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Julien Massot <julien.massot@collabora.com>
> ---
>   drivers/media/v4l2-core/v4l2-ioctl.c | 9 ++++++---
>   1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
> index d125d23e4e61..95bd56145d38 100644
> --- a/drivers/media/v4l2-core/v4l2-ioctl.c
> +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
> @@ -3415,11 +3415,14 @@ video_usercopy(struct file *file, unsigned int orig_cmd, unsigned long arg,
>   	 * FIXME: subdev IOCTLS are partially handled here and partially in
>   	 * v4l2-subdev.c and the 'always_copy' flag can only be set for IOCTLS
>   	 * defined here as part of the 'v4l2_ioctls' array. As
> -	 * VIDIOC_SUBDEV_G_ROUTING needs to return results to applications even
> -	 * in case of failure, but it is not defined here as part of the
> +	 * VIDIOC_SUBDEV_[GS]_ROUTING needs to return results to applications
> +	 * even in case of failure, but it is not defined here as part of the
>   	 * 'v4l2_ioctls' array, insert an ad-hoc check to address that.
>   	 */
> -	if (err < 0 && !always_copy && cmd != VIDIOC_SUBDEV_G_ROUTING)
> +	if (cmd == VIDIOC_SUBDEV_G_ROUTING || cmd == VIDIOC_SUBDEV_S_ROUTING)
> +		always_copy = true;
> +
> +	if (err < 0 && !always_copy)
>   		goto out;
>   
>   	if (has_array_args) {
Laurent Pinchart March 20, 2024, 12:39 a.m. UTC | #2
Hi Sakari,

Thank you for the patch.

On Wed, Mar 13, 2024 at 09:24:51AM +0200, Sakari Ailus wrote:
> As the user needs to know what went wrong for S_ROUTING, copy array
> arguments back to the user.
> 
> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> ---
>  drivers/media/v4l2-core/v4l2-ioctl.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
> index d125d23e4e61..95bd56145d38 100644
> --- a/drivers/media/v4l2-core/v4l2-ioctl.c
> +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
> @@ -3415,11 +3415,14 @@ video_usercopy(struct file *file, unsigned int orig_cmd, unsigned long arg,
>  	 * FIXME: subdev IOCTLS are partially handled here and partially in
>  	 * v4l2-subdev.c and the 'always_copy' flag can only be set for IOCTLS
>  	 * defined here as part of the 'v4l2_ioctls' array. As
> -	 * VIDIOC_SUBDEV_G_ROUTING needs to return results to applications even
> -	 * in case of failure, but it is not defined here as part of the
> +	 * VIDIOC_SUBDEV_[GS]_ROUTING needs to return results to applications

s/needs/need/

Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>

> +	 * even in case of failure, but it is not defined here as part of the
>  	 * 'v4l2_ioctls' array, insert an ad-hoc check to address that.
>  	 */
> -	if (err < 0 && !always_copy && cmd != VIDIOC_SUBDEV_G_ROUTING)
> +	if (cmd == VIDIOC_SUBDEV_G_ROUTING || cmd == VIDIOC_SUBDEV_S_ROUTING)
> +		always_copy = true;
> +
> +	if (err < 0 && !always_copy)
>  		goto out;
>  
>  	if (has_array_args) {
Sakari Ailus April 11, 2024, 8:06 a.m. UTC | #3
Hi Laurent,

Thanks for the review.

On Wed, Mar 20, 2024 at 02:39:07AM +0200, Laurent Pinchart wrote:
> Hi Sakari,
> 
> Thank you for the patch.
> 
> On Wed, Mar 13, 2024 at 09:24:51AM +0200, Sakari Ailus wrote:
> > As the user needs to know what went wrong for S_ROUTING, copy array
> > arguments back to the user.
> > 
> > Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> > ---
> >  drivers/media/v4l2-core/v4l2-ioctl.c | 9 ++++++---
> >  1 file changed, 6 insertions(+), 3 deletions(-)
> > 
> > diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
> > index d125d23e4e61..95bd56145d38 100644
> > --- a/drivers/media/v4l2-core/v4l2-ioctl.c
> > +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
> > @@ -3415,11 +3415,14 @@ video_usercopy(struct file *file, unsigned int orig_cmd, unsigned long arg,
> >  	 * FIXME: subdev IOCTLS are partially handled here and partially in
> >  	 * v4l2-subdev.c and the 'always_copy' flag can only be set for IOCTLS
> >  	 * defined here as part of the 'v4l2_ioctls' array. As
> > -	 * VIDIOC_SUBDEV_G_ROUTING needs to return results to applications even
> > -	 * in case of failure, but it is not defined here as part of the
> > +	 * VIDIOC_SUBDEV_[GS]_ROUTING needs to return results to applications
> 
> s/needs/need/

I'd say "needs" is correct.

> 
> Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> 
> > +	 * even in case of failure, but it is not defined here as part of the
> >  	 * 'v4l2_ioctls' array, insert an ad-hoc check to address that.
> >  	 */
> > -	if (err < 0 && !always_copy && cmd != VIDIOC_SUBDEV_G_ROUTING)
> > +	if (cmd == VIDIOC_SUBDEV_G_ROUTING || cmd == VIDIOC_SUBDEV_S_ROUTING)
> > +		always_copy = true;
> > +
> > +	if (err < 0 && !always_copy)
> >  		goto out;
> >  
> >  	if (has_array_args) {
>
diff mbox series

Patch

diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
index d125d23e4e61..95bd56145d38 100644
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -3415,11 +3415,14 @@  video_usercopy(struct file *file, unsigned int orig_cmd, unsigned long arg,
 	 * FIXME: subdev IOCTLS are partially handled here and partially in
 	 * v4l2-subdev.c and the 'always_copy' flag can only be set for IOCTLS
 	 * defined here as part of the 'v4l2_ioctls' array. As
-	 * VIDIOC_SUBDEV_G_ROUTING needs to return results to applications even
-	 * in case of failure, but it is not defined here as part of the
+	 * VIDIOC_SUBDEV_[GS]_ROUTING needs to return results to applications
+	 * even in case of failure, but it is not defined here as part of the
 	 * 'v4l2_ioctls' array, insert an ad-hoc check to address that.
 	 */
-	if (err < 0 && !always_copy && cmd != VIDIOC_SUBDEV_G_ROUTING)
+	if (cmd == VIDIOC_SUBDEV_G_ROUTING || cmd == VIDIOC_SUBDEV_S_ROUTING)
+		always_copy = true;
+
+	if (err < 0 && !always_copy)
 		goto out;
 
 	if (has_array_args) {