summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntoniu Miclaus <antoniu.miclaus@analog.com>2026-01-29 17:01:45 +0200
committerSasha Levin <sashal@kernel.org>2026-03-04 07:21:13 -0500
commit1eabfd2c437b276a0643017a633e3b6f81d6ca7b (patch)
tree5d014d327775a89b392ae9efe778484e46fb9e54
parent9d0ca11258e7b452653d04310addfec1753de1a2 (diff)
iio: gyro: itg3200: Fix unchecked return value in read_raw
[ Upstream commit b79b24f578cdb2d657db23e5fafe82c7e6a36b72 ] 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: 9dbf091da080 ("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> Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r--drivers/iio/gyro/itg3200_core.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/iio/gyro/itg3200_core.c b/drivers/iio/gyro/itg3200_core.c
index 53fb92f0ac7e..1127dd9f0df2 100644
--- a/drivers/iio/gyro/itg3200_core.c
+++ b/drivers/iio/gyro/itg3200_core.c
@@ -93,6 +93,8 @@ static int itg3200_read_raw(struct iio_dev *indio_dev,
case IIO_CHAN_INFO_RAW:
reg = (u8)chan->address;
ret = itg3200_read_reg_s16(indio_dev, reg, val);
+ if (ret)
+ return ret;
return IIO_VAL_INT;
case IIO_CHAN_INFO_SCALE:
*val = 0;