iio: magnetometer: correct a harmless off by one check
Subsystems (2)
PATCH 1/1 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 >.
drivers/iio/magnetometer/mmc35240.c +1 -1
@@ -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];
Quoted 4 lines · Dan Carpenter
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 <[email protected]>
Good catch.
Quoted 18 lines
drivers/iio/magnetometer/mmc35240.c +1
-2@@ -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]; --To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 10 lines · Daniel Baluta
Quoted 4 lines · Dan Carpenter
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 <[email protected]>Good catch.
Reviewed-by Daniel Baluta <[email protected]>
Applied to the togreg branch of iio.git - initially pushed out as testing when I have a network that does anything other than https.
J
Quoted 24 lines
Quoted 16 lines
drivers/iio/magnetometer/mmc35240.c +1
-2@@ -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]; --Quoted 3 lines
To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html