media: i2c: tc358743: Only allow supported pixel fmts in set_fmt
authorDave Stevenson <dave.stevenson@raspberrypi.com>
Fri, 10 Jul 2020 11:40:50 +0000 (12:40 +0100)
committerDom Cobley <popcornmix@gmail.com>
Mon, 19 Feb 2024 11:33:03 +0000 (11:33 +0000)
Fix commit "media: tc358743: Return an appropriate colorspace from
tc358743_set_fmt" to ensure that the format passed in to set_fmt
is checked to be valid, and reset to the current format if not.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
drivers/media/i2c/tc358743.c

index 16bb2dc..5b6f74e 100644 (file)
@@ -1708,8 +1708,10 @@ static int tc358743_set_fmt(struct v4l2_subdev *sd,
        u32 code = format->format.code; /* is overwritten by get_fmt */
        int ret = tc358743_get_fmt(sd, sd_state, format);
 
-       format->format.code = code;
-       format->format.colorspace = tc358743_g_colorspace(code);
+       if (code == MEDIA_BUS_FMT_RGB888_1X24 ||
+           code == MEDIA_BUS_FMT_UYVY8_1X16)
+               format->format.code = code;
+       format->format.colorspace = tc358743_g_colorspace(format->format.code);
 
        if (ret)
                return ret;