linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] media: i2c: st-mipid02: correct format propagation
@ 2023-11-13 14:57 Alain Volmat
  2023-11-13 16:15 ` Jacopo Mondi
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Alain Volmat @ 2023-11-13 14:57 UTC (permalink / raw)
  To: Benjamin Mugnier, Sylvain Petinot, Mauro Carvalho Chehab,
	Hans Verkuil, Sakari Ailus, Daniel Scally
  Cc: stable, Jacopo Mondi, Alain Volmat, linux-media, linux-kernel

Use a copy of the struct v4l2_subdev_format when propagating
format from the sink to source pad in order to avoid impacting the
sink format returned to the application.

Thanks to Jacopo Mondi for pointing the issue.

Fixes: 6c01e6f3f27b ("media: st-mipid02: Propagate format from sink to source pad")
Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
Cc: stable@vger.kernel.org
---
 drivers/media/i2c/st-mipid02.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/media/i2c/st-mipid02.c b/drivers/media/i2c/st-mipid02.c
index fa27638edc07..dab14787116b 100644
--- a/drivers/media/i2c/st-mipid02.c
+++ b/drivers/media/i2c/st-mipid02.c
@@ -770,6 +770,7 @@ static void mipid02_set_fmt_sink(struct v4l2_subdev *sd,
 				 struct v4l2_subdev_format *format)
 {
 	struct mipid02_dev *bridge = to_mipid02_dev(sd);
+	struct v4l2_subdev_format source_fmt;
 	struct v4l2_mbus_framefmt *fmt;
 
 	format->format.code = get_fmt_code(format->format.code);
@@ -781,8 +782,12 @@ static void mipid02_set_fmt_sink(struct v4l2_subdev *sd,
 
 	*fmt = format->format;
 
-	/* Propagate the format change to the source pad */
-	mipid02_set_fmt_source(sd, sd_state, format);
+	/*
+	 * Propagate the format change to the source pad, taking
+	 * care not to update the format pointer given back to user
+	 */
+	source_fmt = *format;
+	mipid02_set_fmt_source(sd, sd_state, &source_fmt);
 }
 
 static int mipid02_set_fmt(struct v4l2_subdev *sd,
-- 
2.25.1


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

* Re: [PATCH] media: i2c: st-mipid02: correct format propagation
  2023-11-13 14:57 [PATCH] media: i2c: st-mipid02: correct format propagation Alain Volmat
@ 2023-11-13 16:15 ` Jacopo Mondi
  2023-11-14 14:40 ` Benjamin Mugnier
  2023-11-14 15:19 ` Dan Scally
  2 siblings, 0 replies; 4+ messages in thread
From: Jacopo Mondi @ 2023-11-13 16:15 UTC (permalink / raw)
  To: Alain Volmat
  Cc: Benjamin Mugnier, Sylvain Petinot, Mauro Carvalho Chehab,
	Hans Verkuil, Sakari Ailus, Daniel Scally, stable, Jacopo Mondi,
	linux-media, linux-kernel

Hello Alain

On Mon, Nov 13, 2023 at 03:57:30PM +0100, Alain Volmat wrote:
> Use a copy of the struct v4l2_subdev_format when propagating
> format from the sink to source pad in order to avoid impacting the
> sink format returned to the application.
>
> Thanks to Jacopo Mondi for pointing the issue.
>

;)

> Fixes: 6c01e6f3f27b ("media: st-mipid02: Propagate format from sink to source pad")
> Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
> Cc: stable@vger.kernel.org
> ---
>  drivers/media/i2c/st-mipid02.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/media/i2c/st-mipid02.c b/drivers/media/i2c/st-mipid02.c
> index fa27638edc07..dab14787116b 100644
> --- a/drivers/media/i2c/st-mipid02.c
> +++ b/drivers/media/i2c/st-mipid02.c
> @@ -770,6 +770,7 @@ static void mipid02_set_fmt_sink(struct v4l2_subdev *sd,
>  				 struct v4l2_subdev_format *format)
>  {
>  	struct mipid02_dev *bridge = to_mipid02_dev(sd);
> +	struct v4l2_subdev_format source_fmt;
>  	struct v4l2_mbus_framefmt *fmt;
>
>  	format->format.code = get_fmt_code(format->format.code);
> @@ -781,8 +782,12 @@ static void mipid02_set_fmt_sink(struct v4l2_subdev *sd,
>
>  	*fmt = format->format;
>
> -	/* Propagate the format change to the source pad */
> -	mipid02_set_fmt_source(sd, sd_state, format);
> +	/*
> +	 * Propagate the format change to the source pad, taking
> +	 * care not to update the format pointer given back to user
> +	 */
> +	source_fmt = *format;
> +	mipid02_set_fmt_source(sd, sd_state, &source_fmt);

Looks good!
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>

Thanks
  j

>  }
>
>  static int mipid02_set_fmt(struct v4l2_subdev *sd,
> --
> 2.25.1
>

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

* Re: [PATCH] media: i2c: st-mipid02: correct format propagation
  2023-11-13 14:57 [PATCH] media: i2c: st-mipid02: correct format propagation Alain Volmat
  2023-11-13 16:15 ` Jacopo Mondi
@ 2023-11-14 14:40 ` Benjamin Mugnier
  2023-11-14 15:19 ` Dan Scally
  2 siblings, 0 replies; 4+ messages in thread
From: Benjamin Mugnier @ 2023-11-14 14:40 UTC (permalink / raw)
  To: Alain Volmat, Sylvain Petinot, Mauro Carvalho Chehab,
	Hans Verkuil, Sakari Ailus, Daniel Scally
  Cc: stable, Jacopo Mondi, linux-media, linux-kernel

Hello Alain,

Thanks a lot !

On 11/13/23 15:57, Alain Volmat wrote:
> Use a copy of the struct v4l2_subdev_format when propagating
> format from the sink to source pad in order to avoid impacting the
> sink format returned to the application.
> 
> Thanks to Jacopo Mondi for pointing the issue.

Reviewed-by: Benjamin Mugnier <benjamin.mugnier@foss.st.com>

> Fixes: 6c01e6f3f27b ("media: st-mipid02: Propagate format from sink to source pad")
> Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
> Cc: stable@vger.kernel.org
> ---
>  drivers/media/i2c/st-mipid02.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/media/i2c/st-mipid02.c b/drivers/media/i2c/st-mipid02.c
> index fa27638edc07..dab14787116b 100644
> --- a/drivers/media/i2c/st-mipid02.c
> +++ b/drivers/media/i2c/st-mipid02.c
> @@ -770,6 +770,7 @@ static void mipid02_set_fmt_sink(struct v4l2_subdev *sd,
>  				 struct v4l2_subdev_format *format)
>  {
>  	struct mipid02_dev *bridge = to_mipid02_dev(sd);
> +	struct v4l2_subdev_format source_fmt;
>  	struct v4l2_mbus_framefmt *fmt;
>  
>  	format->format.code = get_fmt_code(format->format.code);
> @@ -781,8 +782,12 @@ static void mipid02_set_fmt_sink(struct v4l2_subdev *sd,
>  
>  	*fmt = format->format;
>  
> -	/* Propagate the format change to the source pad */
> -	mipid02_set_fmt_source(sd, sd_state, format);
> +	/*
> +	 * Propagate the format change to the source pad, taking
> +	 * care not to update the format pointer given back to user
> +	 */
> +	source_fmt = *format;
> +	mipid02_set_fmt_source(sd, sd_state, &source_fmt);
>  }
>  
>  static int mipid02_set_fmt(struct v4l2_subdev *sd,

-- 
Regards,

Benjamin

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

* Re: [PATCH] media: i2c: st-mipid02: correct format propagation
  2023-11-13 14:57 [PATCH] media: i2c: st-mipid02: correct format propagation Alain Volmat
  2023-11-13 16:15 ` Jacopo Mondi
  2023-11-14 14:40 ` Benjamin Mugnier
@ 2023-11-14 15:19 ` Dan Scally
  2 siblings, 0 replies; 4+ messages in thread
From: Dan Scally @ 2023-11-14 15:19 UTC (permalink / raw)
  To: Alain Volmat, Benjamin Mugnier, Sylvain Petinot,
	Mauro Carvalho Chehab, Hans Verkuil, Sakari Ailus
  Cc: stable, Jacopo Mondi, linux-media, linux-kernel

Hi Alain

On 13/11/2023 14:57, Alain Volmat wrote:
> Use a copy of the struct v4l2_subdev_format when propagating
> format from the sink to source pad in order to avoid impacting the
> sink format returned to the application.
>
> Thanks to Jacopo Mondi for pointing the issue.
>
> Fixes: 6c01e6f3f27b ("media: st-mipid02: Propagate format from sink to source pad")
> Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
> Cc: stable@vger.kernel.org
> ---

Oops - sorry about that!


Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>

>   drivers/media/i2c/st-mipid02.c | 9 +++++++--
>   1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/media/i2c/st-mipid02.c b/drivers/media/i2c/st-mipid02.c
> index fa27638edc07..dab14787116b 100644
> --- a/drivers/media/i2c/st-mipid02.c
> +++ b/drivers/media/i2c/st-mipid02.c
> @@ -770,6 +770,7 @@ static void mipid02_set_fmt_sink(struct v4l2_subdev *sd,
>   				 struct v4l2_subdev_format *format)
>   {
>   	struct mipid02_dev *bridge = to_mipid02_dev(sd);
> +	struct v4l2_subdev_format source_fmt;
>   	struct v4l2_mbus_framefmt *fmt;
>   
>   	format->format.code = get_fmt_code(format->format.code);
> @@ -781,8 +782,12 @@ static void mipid02_set_fmt_sink(struct v4l2_subdev *sd,
>   
>   	*fmt = format->format;
>   
> -	/* Propagate the format change to the source pad */
> -	mipid02_set_fmt_source(sd, sd_state, format);
> +	/*
> +	 * Propagate the format change to the source pad, taking
> +	 * care not to update the format pointer given back to user
> +	 */
> +	source_fmt = *format;
> +	mipid02_set_fmt_source(sd, sd_state, &source_fmt);
>   }
>   
>   static int mipid02_set_fmt(struct v4l2_subdev *sd,

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

end of thread, other threads:[~2023-11-14 15:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-13 14:57 [PATCH] media: i2c: st-mipid02: correct format propagation Alain Volmat
2023-11-13 16:15 ` Jacopo Mondi
2023-11-14 14:40 ` Benjamin Mugnier
2023-11-14 15:19 ` Dan Scally

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).