* [PATCH] iio: chemical: ags02ma: Check for short I2C reads
@ 2026-10-13 17:17 Nikhil Gautam
2026-10-15 13:55 ` Joshua Crofts
0 siblings, 1 reply; 2+ messages in thread
From: Nikhil Gautam @ 2026-10-13 17:17 UTC (permalink / raw)
To: anshulusr
Cc: jic23, dlechner, nuno.sa, andy, linux-iio, linux-kernel,
Nikhil Gautam
Check that the I2C receive operation transfers the expected number
of bytes before accessing the received data.
Return -EIO if the transfer is incomplete.
Signed-off-by: Nikhil Gautam <nikhilgtr@gmail.com>
---
drivers/iio/chemical/ags02ma.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/iio/chemical/ags02ma.c b/drivers/iio/chemical/ags02ma.c
index 151178d4e8f4..2219965d044f 100644
--- a/drivers/iio/chemical/ags02ma.c
+++ b/drivers/iio/chemical/ags02ma.c
@@ -61,6 +61,12 @@ static int ags02ma_register_read(struct i2c_client *client, u8 reg, u16 delay,
return ret;
}
+ if (ret != sizeof(read_buffer)) {
+ dev_err(&client->dev,
+ "Short read from register 0x%x\n", reg);
+ return -EIO;
+ }
+
crc = crc8(ags02ma_crc8_table, (u8 *)&read_buffer.data,
sizeof(read_buffer.data), AGS02MA_CRC8_INIT);
if (crc != read_buffer.crc) {
--
2.39.5
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] iio: chemical: ags02ma: Check for short I2C reads
2026-10-13 17:17 [PATCH] iio: chemical: ags02ma: Check for short I2C reads Nikhil Gautam
@ 2026-10-15 13:55 ` Joshua Crofts
0 siblings, 0 replies; 2+ messages in thread
From: Joshua Crofts @ 2026-10-15 13:55 UTC (permalink / raw)
To: Nikhil Gautam
Cc: anshulusr, jic23, dlechner, nuno.sa, andy, linux-iio,
linux-kernel
On Tue, 13 Oct 2026 22:47:26 +0530
Nikhil Gautam <nikhilgtr@gmail.com> wrote:
> Check that the I2C receive operation transfers the expected number
> of bytes before accessing the received data.
>
> Return -EIO if the transfer is incomplete.
>
> Signed-off-by: Nikhil Gautam <nikhilgtr@gmail.com>
> ---
Fine by me. This is more hardening than a fix so no need for a
fixes tag.
Reviewed-by: Joshua Crofts <joshua.crofts1@gmail.com>
--
Kind regards,
Joshua Crofts
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-10-15 13:55 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-13 17:17 [PATCH] iio: chemical: ags02ma: Check for short I2C reads Nikhil Gautam
2026-10-15 13:55 ` Joshua Crofts
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.