mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
iio: accel: kionix-kx022a: Fix array boundary check
The driver performs a sanity check for an array size, when converting a
register value to an array index. The check incorrectly accepts the
sizeof(array) as a last index, when last valid index should be
sizeof(array) - 1.
Fix the check by bailing out when index >= sizeof(array).
Fixes: 7c1d1677b3 ("iio: accel: Support Kionix/ROHM KX022A accelerometer")
Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
Reviewed-by: Mehdi Djait <mehdi.djait@linux.intel.com>
Signed-off-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
This commit is contained in:
parent
4e5b0b7c5d
commit
0e65412aee
|
|
@ -649,7 +649,7 @@ static int kx022a_read_raw(struct iio_dev *idev,
|
|||
if (ret)
|
||||
return ret;
|
||||
|
||||
if ((regval & KX022A_MASK_ODR) >
|
||||
if ((regval & KX022A_MASK_ODR) >=
|
||||
ARRAY_SIZE(kx022a_accel_samp_freq_table)) {
|
||||
dev_err(data->dev, "Invalid ODR\n");
|
||||
return -EINVAL;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user