Skip to content

Commit b79b24f

Browse files
amiclausjic23
authored andcommitted
iio: gyro: itg3200: Fix unchecked return value in read_raw
The return value from itg3200_read_reg_s16() is stored in ret but never checked. The function unconditionally returns IIO_VAL_INT, ignoring potential I2C read failures. This causes garbage data to be returned to userspace when the read fails, with no error reported. Add proper error checking to propagate the failure to callers. Fixes: 9dbf091 ("iio: gyro: Add itg3200") Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com> Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
1 parent 53f0a73 commit b79b24f

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

drivers/iio/gyro/itg3200_core.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ static int itg3200_read_raw(struct iio_dev *indio_dev,
9393
case IIO_CHAN_INFO_RAW:
9494
reg = (u8)chan->address;
9595
ret = itg3200_read_reg_s16(indio_dev, reg, val);
96+
if (ret)
97+
return ret;
9698
return IIO_VAL_INT;
9799
case IIO_CHAN_INFO_SCALE:
98100
*val = 0;

0 commit comments

Comments
 (0)