Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

iio: temperature: Use iio_push_to_buffers_with_ts() to provide length for runtime checks.

This new function allows us to perform debug checks in the helper to ensure
that the overrun does not occur. Use it in all the simple cases where
either a static buffer or a structure is used in the drivers.

Reviewed-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250413103443.2420727-15-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

+8 -6
+3 -2
drivers/iio/temperature/hid-sensor-temperature.c
··· 131 131 struct temperature_state *temp_st = iio_priv(indio_dev); 132 132 133 133 if (atomic_read(&temp_st->common_attributes.data_ready)) 134 - iio_push_to_buffers_with_timestamp(indio_dev, &temp_st->scan, 135 - iio_get_time_ns(indio_dev)); 134 + iio_push_to_buffers_with_ts(indio_dev, &temp_st->scan, 135 + sizeof(temp_st->scan), 136 + iio_get_time_ns(indio_dev)); 136 137 137 138 return 0; 138 139 }
+3 -2
drivers/iio/temperature/maxim_thermocouple.c
··· 168 168 169 169 ret = spi_read(data->spi, data->buffer, data->chip->read_size); 170 170 if (!ret) { 171 - iio_push_to_buffers_with_timestamp(indio_dev, data->buffer, 172 - iio_get_time_ns(indio_dev)); 171 + iio_push_to_buffers_with_ts(indio_dev, data->buffer, 172 + sizeof(data->buffer), 173 + iio_get_time_ns(indio_dev)); 173 174 } 174 175 175 176 iio_trigger_notify_done(indio_dev->trig);
+2 -2
drivers/iio/temperature/tmp006.c
··· 269 269 goto err; 270 270 scan.channels[1] = ret; 271 271 272 - iio_push_to_buffers_with_timestamp(indio_dev, &scan, 273 - iio_get_time_ns(indio_dev)); 272 + iio_push_to_buffers_with_ts(indio_dev, &scan, sizeof(scan), 273 + iio_get_time_ns(indio_dev)); 274 274 err: 275 275 iio_trigger_notify_done(indio_dev->trig); 276 276 return IRQ_HANDLED;