提交 5517547b 编写于 作者: D Dan Carpenter 提交者: Jonathan Cameron

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: NDan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: NDaniel Baluta <daniel.baluta@intel.com>
Signed-off-by: NJonathan Cameron <jic23@kernel.org>
上级 1e1ec286
...@@ -308,7 +308,7 @@ static int mmc35240_read_raw(struct iio_dev *indio_dev, ...@@ -308,7 +308,7 @@ static int mmc35240_read_raw(struct iio_dev *indio_dev,
return ret; return ret;
i = (reg & MMC35240_CTRL1_BW_MASK) >> MMC35240_CTRL1_BW_SHIFT; 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; return -EINVAL;
*val = mmc35240_samp_freq[i]; *val = mmc35240_samp_freq[i];
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册