media: i2c: st-mipid02: correct format propagation
authorAlain Volmat <alain.volmat@foss.st.com>
Mon, 13 Nov 2023 14:57:30 +0000 (15:57 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 1 Feb 2024 00:18:55 +0000 (16:18 -0800)
commit b33cb0cbe2893b96ecbfa16254407153f4b55d16 upstream.

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
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
Reviewed-by: Benjamin Mugnier <benjamin.mugnier@foss.st.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/media/i2c/st-mipid02.c

index fa27638..dab1478 100644 (file)
@@ -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,