Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

iio: tsl2583: make array large enough

This array is supposed to have 10 elements. Smatch complains that with
the current code we can have n == max_ints and read beyond the end of
the array.

Fixes: ac4f6eee8fe8 ("staging: iio: TAOS tsl258x: Device driver")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Brian Masney <masneyb@onstation.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>

authored by

Dan Carpenter and committed by
Jonathan Cameron
0e8d2b0f 9049531c

+1 -1
+1 -1
drivers/iio/light/tsl2583.c
··· 565 565 struct iio_dev *indio_dev = dev_to_iio_dev(dev); 566 566 struct tsl2583_chip *chip = iio_priv(indio_dev); 567 567 const unsigned int max_ints = TSL2583_MAX_LUX_TABLE_ENTRIES * 3; 568 - int value[TSL2583_MAX_LUX_TABLE_ENTRIES * 3]; 568 + int value[TSL2583_MAX_LUX_TABLE_ENTRIES * 3 + 1]; 569 569 int ret = -EINVAL; 570 570 unsigned int n; 571 571