[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260129150151.127713-1-antoniu.miclaus@analog.com>
Date: Thu, 29 Jan 2026 17:01:45 +0200
From: Antoniu Miclaus <antoniu.miclaus@...log.com>
To: Jonathan Cameron <jic23@...nel.org>,
David Lechner
<dlechner@...libre.com>,
Nuno Sá <nuno.sa@...log.com>,
Andy Shevchenko <andy@...nel.org>,
Petre Rodan <petre.rodan@...dimension.ro>,
Antoniu Miclaus <antoniu.miclaus@...log.com>,
Manuel Stahl
<manuel.stahl@....fraunhofer.de>,
Lars-Peter Clausen <lars@...afoo.de>, <linux-iio@...r.kernel.org>,
<linux-kernel@...r.kernel.org>
Subject: [PATCH] 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: 9dbf091da080 ("iio: gyro: Add itg3200")
Signed-off-by: Antoniu Miclaus <antoniu.miclaus@...log.com>
---
drivers/iio/gyro/itg3200_core.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/iio/gyro/itg3200_core.c b/drivers/iio/gyro/itg3200_core.c
index cd8a2dae56cd..bfe95ec1abda 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;
--
2.43.0
Powered by blists - more mailing lists