]> git.baikalelectronics.ru Git - kernel.git/commit
media: atomisp2: array underflow in imx_enum_frame_size()
authorDan Carpenter <dan.carpenter@oracle.com>
Wed, 19 Jul 2017 09:58:20 +0000 (05:58 -0400)
committerMauro Carvalho Chehab <mchehab@s-opensource.com>
Wed, 26 Jul 2017 12:26:21 +0000 (08:26 -0400)
commit2d64940daa10fba429afa94004097501ddaef47b
tree04f8e515f1fd16bc7dfc88a700a7b6e601840bb0
parenta3f499240a0b3a929e2134d3ab1035a4ac32a06c
media: atomisp2: array underflow in imx_enum_frame_size()

The code looks in imx_enum_frame_size() looks like this:

  2066          int index = fse->index;
  2067          struct imx_device *dev = to_imx_sensor(sd);
  2068
  2069          mutex_lock(&dev->input_lock);
  2070          if (index >= dev->entries_curr_table) {
  2071                  mutex_unlock(&dev->input_lock);
  2072                  return -EINVAL;
  2073          }
  2074
  2075          fse->min_width = dev->curr_res_table[index].width;

"fse->index" is a u32 that comes from the user.  We want negative values
of "index" to be -EINVAL so we don't read before the start of the
dev->curr_res_table[] array.  I've made "entries_curr_table" unsigned
long to fix this.  I thought about making it unsigned int, but because
of struct alignment, it doesn't use more memory either way.

Fixes: f40413881fa2 ("staging/atomisp: Add support for the Intel IPU v2")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
drivers/staging/media/atomisp/i2c/imx/imx.h
drivers/staging/media/atomisp/i2c/ov8858.h
drivers/staging/media/atomisp/i2c/ov8858_btns.h