From: Dan Carpenter Date: Wed, 27 May 2015 08:20:52 +0000 (+0300) Subject: iio: magnetometer: correct a harmless off by one check X-Git-Tag: firefly_0821_release~176^2~1545^2~256^2~16 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=5517547bf44731621338c1a4047196a49c790719;p=firefly-linux-kernel-4.4.55.git iio: magnetometer: correct a harmless off by one check The line before limits i to 0-3 so the existing code works fine but the check is still off by one and >= is intended instead of >. Signed-off-by: Dan Carpenter Reviewed-by: Daniel Baluta Signed-off-by: Jonathan Cameron --- diff --git a/drivers/iio/magnetometer/mmc35240.c b/drivers/iio/magnetometer/mmc35240.c index aa6e25d3bfc3..c71392cf1370 100644 --- a/drivers/iio/magnetometer/mmc35240.c +++ b/drivers/iio/magnetometer/mmc35240.c @@ -308,7 +308,7 @@ static int mmc35240_read_raw(struct iio_dev *indio_dev, return ret; i = (reg & MMC35240_CTRL1_BW_MASK) >> MMC35240_CTRL1_BW_SHIFT; - if (i < 0 || i > ARRAY_SIZE(mmc35240_samp_freq)) + if (i < 0 || i >= ARRAY_SIZE(mmc35240_samp_freq)) return -EINVAL; *val = mmc35240_samp_freq[i];