Skip to content

Commit

Permalink
media: ov7740: avoid invalid framesize setting
Browse files Browse the repository at this point in the history
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 <[email protected]>
Cc: Eugen Hristev <[email protected]>
Signed-off-by: Akinobu Mita <[email protected]>
Signed-off-by: Sakari Ailus <[email protected]>
Signed-off-by: Mauro Carvalho Chehab <[email protected]>
  • Loading branch information
mita authored and mchehab committed May 23, 2019
1 parent cfe7cc3 commit 6e4ab83
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion drivers/media/i2c/ov7740.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 6e4ab83

Please sign in to comment.