drivers/iio/light/as73211.c:213 as73211_integration_time_calc_avail() error: buffer overflow 'data->int_time_avail' 30 <= 58
PATCH 17/95 drivers/iio/light/as73211.c:213 as73211_integration_time_calc_avail() error: buffer overflow 'data->int_time_avail' 30 <= 58
tree: https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git testing head: 283d2403beb406f0906cfbb2c9d7aa61cbcbbeed commit: 77ed24daa40b3ce41610268d8307a50d82b382ad [17/95] iio: light: as73211: New driver config: mips-randconfig-m031-20200831 (attached as .config) compiler: mips-linux-gcc (GCC) 9.3.0
If you fix the issue, kindly add following tag as appropriate
New smatch warnings:drivers/iio/light/as73211.c:213 as73211_integration_time_calc_avail() error: buffer overflow 'data->int_time_avail' 30 <= 58
# https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git/commit/?id=77ed24daa40b3ce41610268d8307a50d82b382ad
git remote add iio https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git
git fetch --no-tags iio testing
git checkout 77ed24daa40b3ce41610268d8307a50d82b382ad
vim +213 drivers/iio/light/as73211.c
77ed24daa40b3c Christian Eggers 2020-08-05 206 static void as73211_integration_time_calc_avail(struct as73211_data *data)
77ed24daa40b3c Christian Eggers 2020-08-05 207 {
77ed24daa40b3c Christian Eggers 2020-08-05 208 int i;
77ed24daa40b3c Christian Eggers 2020-08-05 209
77ed24daa40b3c Christian Eggers 2020-08-05 210 for (i = 0; i < ARRAY_SIZE(data->int_time_avail); i++) {
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^77ed24daa40b3c Christian Eggers 2020-08-05 211 unsigned int time_us = as73211_integration_time_us(data, BIT(i));77ed24daa40b3c Christian Eggers 2020-08-05 212
77ed24daa40b3c Christian Eggers 2020-08-05 @213 data->int_time_avail[i * 2 + 0] = time_us / USEC_PER_SEC;
^^^^^^^^^Buffer overflow
77ed24daa40b3c Christian Eggers 2020-08-05 214 data->int_time_avail[i * 2 + 1] = time_us % USEC_PER_SEC;
^^^^^^^^^^^^^^^^^^^^^^^^77ed24daa40b3c Christian Eggers 2020-08-05 215 } 77ed24daa40b3c Christian Eggers 2020-08-05 216 }
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
Quoted 10 lines · Dan Carpenter
tree: https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git testing head: 283d2403beb406f0906cfbb2c9d7aa61cbcbbeed commit: 77ed24daa40b3ce41610268d8307a50d82b382ad [17/95] iio: light: as73211: New driver config: mips-randconfig-m031-20200831 (attached as .config) compiler: mips-linux-gcc (GCC) 9.3.0If you fix the issue, kindly add following tag as appropriate
Reported-by kernel test robot <[email protected]>Reported-by Dan Carpenter <[email protected]>
Good catch! This
int int_time_avail[AS73211_SAMPLE_TIME_NUM * 2];
should be like
int int_time_avail[AS73211_SAMPLE_TIME_NUM][2];
and code changed accordingly.
Signature · 2 lines
With Best Regards, Andy Shevchenko