Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

media: omap3isp: isp_video_mbus_to_pix/pix_to_mbus fixes

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>

+3 -3
+3 -3
drivers/media/platform/ti/omap3isp/ispvideo.c
··· 148 148 pix->width = mbus->width; 149 149 pix->height = mbus->height; 150 150 151 - for (i = 0; i < ARRAY_SIZE(formats); ++i) { 151 + for (i = 0; i < ARRAY_SIZE(formats) - 1; ++i) { 152 152 if (formats[i].code == mbus->code) 153 153 break; 154 154 } 155 155 156 - if (WARN_ON(i == ARRAY_SIZE(formats))) 156 + if (WARN_ON(i == ARRAY_SIZE(formats) - 1)) 157 157 return 0; 158 158 159 159 min_bpl = pix->width * formats[i].bpp; ··· 191 191 /* Skip the last format in the loop so that it will be selected if no 192 192 * match is found. 193 193 */ 194 - for (i = 0; i < ARRAY_SIZE(formats) - 1; ++i) { 194 + for (i = 0; i < ARRAY_SIZE(formats) - 2; ++i) { 195 195 if (formats[i].pixelformat == pix->pixelformat) 196 196 break; 197 197 }