]> git.baikalelectronics.ru Git - kernel.git/commit
media: atomisp2: array underflow in ap1302_enum_frame_size()
authorDan Carpenter <dan.carpenter@oracle.com>
Wed, 19 Jul 2017 09:56:18 +0000 (05:56 -0400)
committerMauro Carvalho Chehab <mchehab@s-opensource.com>
Wed, 26 Jul 2017 12:25:25 +0000 (08:25 -0400)
commita3f499240a0b3a929e2134d3ab1035a4ac32a06c
treeb59c4e6070002cea07ff3deb6a6a94546903e79d
parentc2e77722528b33f5d3674409ae9d449fd0dad79b
media: atomisp2: array underflow in ap1302_enum_frame_size()

The problem is this code from ap1302_enum_frame_size():

   738          int index = fse->index;
   739
   740          mutex_lock(&dev->input_lock);
   741          context = ap1302_get_context(sd);
   742          if (index >= dev->cntx_res[context].res_num) {
   743                  mutex_unlock(&dev->input_lock);
   744                  return -EINVAL;
   745          }
   746
   747          res_table = dev->cntx_res[context].res_table;
   748          fse->min_width = res_table[index].width;

"fse->index" is a u32 that come from the user.  We want negative values
of "index" to be treated as -EINVAL but they're not so we can read from
before the start of the res_table[] array.

I've fixed this by making "res_num" a u32.  I made "cur_res" a u32 as
well, just for consistency.

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/ap1302.h