diff mbox series

[04/16] iio: adc: ti-ads131e08: Use new iio_push_to_buffers_with_ts() to provide length sanity check.

Message ID 20250309182100.1351128-5-jic23@kernel.org (mailing list archive)
State New
Headers show
Series IIO: Introduce iio_push_to_buffers_with_ts() taking an input buffer length argument. | expand

Commit Message

Jonathan Cameron March 9, 2025, 6:20 p.m. UTC
From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

By providing the size of the buffer used, runtime checks can be performed
to ensure not overrun.

Also change the pushed data pointer to be that of the structure that also
contains the timestamp.  Not an actual bug but semantically incorrect
to push the channel data when we want the storage with the timestamp
as well.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 drivers/iio/adc/ti-ads131e08.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

David Lechner March 10, 2025, 10:07 p.m. UTC | #1
On 3/9/25 1:20 PM, Jonathan Cameron wrote:
> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> 
> By providing the size of the buffer used, runtime checks can be performed
> to ensure not overrun.
> 
> Also change the pushed data pointer to be that of the structure that also
> contains the timestamp.  Not an actual bug but semantically incorrect
> to push the channel data when we want the storage with the timestamp
> as well.
> 
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> ---

Reviewed-by: David Lechner <dlechner@baylibre.com>
diff mbox series

Patch

diff --git a/drivers/iio/adc/ti-ads131e08.c b/drivers/iio/adc/ti-ads131e08.c
index c6096b64664e..6e83d370f0b5 100644
--- a/drivers/iio/adc/ti-ads131e08.c
+++ b/drivers/iio/adc/ti-ads131e08.c
@@ -664,8 +664,9 @@  static irqreturn_t ads131e08_trigger_handler(int irq, void *private)
 		i++;
 	}
 
-	iio_push_to_buffers_with_timestamp(indio_dev, st->tmp_buf.data,
-		iio_get_time_ns(indio_dev));
+	iio_push_to_buffers_with_ts(indio_dev, &st->tmp_buf,
+				    sizeof(st->tmp_buf),
+				    iio_get_time_ns(indio_dev));
 
 out:
 	iio_trigger_notify_done(indio_dev->trig);