public inbox for linux-iio@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] iio: gyro: itg3200: Fix unchecked return value in read_raw
@ 2026-01-29 15:01 Antoniu Miclaus
  2026-01-29 15:01 ` [PATCH] iio: pressure: hsc030pa: Fix i2c_transfer return value check Antoniu Miclaus
  2026-01-29 15:53 ` [PATCH] iio: gyro: itg3200: Fix unchecked return value in read_raw Andy Shevchenko
  0 siblings, 2 replies; 6+ messages in thread
From: Antoniu Miclaus @ 2026-01-29 15:01 UTC (permalink / raw)
  To: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
	Petre Rodan, Antoniu Miclaus, Manuel Stahl, Lars-Peter Clausen,
	linux-iio, linux-kernel

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>
---
 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


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-01-29 17:07 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-29 15:01 [PATCH] iio: gyro: itg3200: Fix unchecked return value in read_raw Antoniu Miclaus
2026-01-29 15:01 ` [PATCH] iio: pressure: hsc030pa: Fix i2c_transfer return value check Antoniu Miclaus
2026-01-29 15:54   ` Andy Shevchenko
2026-01-29 17:06   ` Jonathan Cameron
2026-01-29 15:53 ` [PATCH] iio: gyro: itg3200: Fix unchecked return value in read_raw Andy Shevchenko
2026-01-29 17:07   ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox