From: Akinobu Mita Date: Wed, 17 Apr 2019 14:06:39 +0000 (-0400) Subject: media: ov7740: avoid invalid framesize setting X-Git-Tag: v4.19.61~253 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=add712b63185608ed961d8d58656164a89288d6f;p=platform%2Fkernel%2Flinux-rpi.git media: ov7740: avoid invalid framesize setting [ 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 Cc: Eugen Hristev Signed-off-by: Akinobu Mita Signed-off-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- diff --git a/drivers/media/i2c/ov7740.c b/drivers/media/i2c/ov7740.c index f5a1ee9..8a6a7a5 100644 --- a/drivers/media/i2c/ov7740.c +++ b/drivers/media/i2c/ov7740.c @@ -761,7 +761,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;