]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
media: ov7740: avoid invalid framesize setting
authorAkinobu Mita <akinobu.mita@gmail.com>
Wed, 17 Apr 2019 14:06:39 +0000 (10:06 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 26 Jul 2019 07:10:13 +0000 (09:10 +0200)
[ Upstream commit 6e4ab830ac6d6a0d7cd7f87dc5d6536369bf24a8 ]

If the requested framesize by VIDIOC_SUBDEV_S_FMT is larger than supported
framesizes, it causes an out of bounds array access and the resulting
framesize is unexpected.

Avoid out of bounds array access and select the default framesize.

Cc: Wenyou Yang <wenyou.yang@microchip.com>
Cc: Eugen Hristev <eugen.hristev@microchip.com>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/media/i2c/ov7740.c

index 54e80a60aa579fbf83d76fc0c28c599dbd5bc5ed..63011d4b473880dad8d30ce9a294ac15a76927d1 100644 (file)
@@ -785,7 +785,11 @@ static int ov7740_try_fmt_internal(struct v4l2_subdev *sd,
 
                fsize++;
        }
-
+       if (i >= ARRAY_SIZE(ov7740_framesizes)) {
+               fsize = &ov7740_framesizes[0];
+               fmt->width = fsize->width;
+               fmt->height = fsize->height;
+       }
        if (ret_frmsize != NULL)
                *ret_frmsize = fsize;