iio: tsl2583: make array large enough
authorDan Carpenter <dan.carpenter@oracle.com>
Thu, 24 Nov 2016 13:38:07 +0000 (16:38 +0300)
committerJonathan Cameron <jic23@kernel.org>
Thu, 24 Nov 2016 20:09:55 +0000 (20:09 +0000)
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>
drivers/iio/light/tsl2583.c

index 0b87f6adbb79cb4a9c514c98b97bd0f961a5dfc7..a78b6025c465217d78e0bfdde930b35418ffbc0e 100644 (file)
@@ -565,7 +565,7 @@ static ssize_t in_illuminance_lux_table_store(struct device *dev,
        struct iio_dev *indio_dev = dev_to_iio_dev(dev);
        struct tsl2583_chip *chip = iio_priv(indio_dev);
        const unsigned int max_ints = TSL2583_MAX_LUX_TABLE_ENTRIES * 3;
-       int value[TSL2583_MAX_LUX_TABLE_ENTRIES * 3];
+       int value[TSL2583_MAX_LUX_TABLE_ENTRIES * 3 + 1];
        int ret = -EINVAL;
        unsigned int n;