]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
media: omap3isp: isp_video_mbus_to_pix/pix_to_mbus fixes
authorHans Verkuil <hverkuil+cisco@kernel.org>
Fri, 17 Oct 2025 13:26:40 +0000 (15:26 +0200)
committerHans Verkuil <hverkuil+cisco@kernel.org>
Tue, 6 Jan 2026 07:22:46 +0000 (08:22 +0100)
The isp_video_mbus_to_pix/pix_to_mbus functions did not take
the last empty entry { 0, } of the formats array into account.

As a result, isp_video_mbus_to_pix would accept code 0 and
isp_video_pix_to_mbus would select code 0 if no match was found.

Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
drivers/media/platform/ti/omap3isp/ispvideo.c

index 46609045e2c8f487736eb5e97ef241761aee0921..864d38140b8735302a53b23f18f5f600ed5e1998 100644 (file)
@@ -148,12 +148,12 @@ static unsigned int isp_video_mbus_to_pix(const struct isp_video *video,
        pix->width = mbus->width;
        pix->height = mbus->height;
 
-       for (i = 0; i < ARRAY_SIZE(formats); ++i) {
+       for (i = 0; i < ARRAY_SIZE(formats) - 1; ++i) {
                if (formats[i].code == mbus->code)
                        break;
        }
 
-       if (WARN_ON(i == ARRAY_SIZE(formats)))
+       if (WARN_ON(i == ARRAY_SIZE(formats) - 1))
                return 0;
 
        min_bpl = pix->width * formats[i].bpp;
@@ -191,7 +191,7 @@ static void isp_video_pix_to_mbus(const struct v4l2_pix_format *pix,
        /* Skip the last format in the loop so that it will be selected if no
         * match is found.
         */
-       for (i = 0; i < ARRAY_SIZE(formats) - 1; ++i) {
+       for (i = 0; i < ARRAY_SIZE(formats) - 2; ++i) {
                if (formats[i].pixelformat == pix->pixelformat)
                        break;
        }