linux/drivers/iio
David Lechner 01bc94b581 iio: triggered-buffer: prevent possible freeing of wrong buffer
commit bce61476dc upstream.

Commit ee708e6baa ("iio: buffer: introduce support for attaching more
IIO buffers") introduced support for multiple buffers per indio_dev but
left indio_dev->buffer for a few legacy use cases.

In the case of the triggered buffer, iio_triggered_buffer_cleanup()
still assumes that indio_dev->buffer points to the buffer allocated by
iio_triggered_buffer_setup_ext(). However, since
iio_triggered_buffer_setup_ext() now calls iio_device_attach_buffer()
to attach the buffer, indio_dev->buffer will only point to the buffer
allocated by iio_device_attach_buffer() if it the first buffer attached.

This adds a check to make sure that no other buffer has been attached
yet to ensure that indio_dev->buffer will be assigned when
iio_device_attach_buffer() is called.

As per discussion in the review thread, we may want to deal with multiple
triggers per device, but this is a fix for the issue in the meantime and
any such support would be unlikely to be suitable for a backport.

Fixes: ee708e6baa ("iio: buffer: introduce support for attaching more IIO buffers")
Signed-off-by: David Lechner <dlechner@baylibre.com>
Acked-by: Nuno Sa <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20231031210521.1661552-1-dlechner@baylibre.com
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-01-01 12:39:01 +00:00
..
accel
adc iio: adc: ti_am335x_adc: Fix return value check of tiadc_request_dma() 2024-01-01 12:39:01 +00:00
addac iio: addac: Kconfig: update ad74413r selections 2023-10-19 23:08:55 +02:00
afe iio: afe: rescale: Accept only offset channels 2023-11-02 09:35:29 +01:00
amplifiers
buffer iio: triggered-buffer: prevent possible freeing of wrong buffer 2024-01-01 12:39:01 +00:00
cdc
chemical
common iio: common: ms_sensors: ms_sensors_i2c: fix humidity conversion time table 2024-01-01 12:39:01 +00:00
dac iio: dac: ad3552r: Correct device IDs 2023-10-19 23:08:55 +02:00
dummy
filter
frequency iio: frequency: adf4350: Use device managed functions and fix power down issue. 2023-11-20 11:52:09 +01:00
gyro
health
humidity
imu iio: imu: inv_mpu6050: fix an error code problem in inv_mpu6050_read_raw 2024-01-01 12:39:00 +00:00
light
magnetometer
multiplexer
orientation
position
potentiometer
potentiostat
pressure iio: pressure: ms5611: ms5611_prom_is_valid false negative bug 2023-10-19 23:08:55 +02:00
proximity
resolver
temperature
test
trigger
iio_core_trigger.h
iio_core.h
industrialio-buffer.c
industrialio-configfs.c
industrialio-core.c iio: core: introduce iio_device_{claim|release}_buffer_mode() APIs 2023-10-25 12:03:09 +02:00
industrialio-event.c
industrialio-sw-device.c
industrialio-sw-trigger.c
industrialio-trigger.c
industrialio-triggered-event.c
inkern.c
Kconfig
Makefile
TODO