WSL2-Linux-Kernel/drivers/iio
David Lechner 5a16bb60b8 iio: triggered-buffer: prevent possible freeing of wrong buffer
commit bce61476dc82f114e24e9c2e11fb064781ec563c 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-05 15:13:32 +01:00
..
accel iio: core: Hide read accesses to iio_dev->currentmode 2023-10-25 11:58:58 +02:00
adc iio: adc: ti_am335x_adc: Fix return value check of tiadc_request_dma() 2024-01-05 15:13:32 +01:00
addac iio: addac: stx104: Fix race condition when converting analog-to-digital 2023-08-26 14:23:27 +02:00
afe iio: afe: rescale: Accept only offset channels 2023-11-08 17:26:42 +01:00
amplifiers
buffer iio: triggered-buffer: prevent possible freeing of wrong buffer 2024-01-05 15:13:32 +01:00
cdc
chemical iio:chemical:ccs811: rearrange iio trigger get and register 2022-06-29 09:03:28 +02:00
common iio: common: ms_sensors: ms_sensors_i2c: fix humidity conversion time table 2024-01-05 15:13:32 +01:00
dac iio: dac: build ad5758 driver when AD5758 is selected 2023-06-09 10:32:28 +02:00
dummy iio: dummy: iio_simple_dummy: check the return value of kstrdup() 2022-06-14 18:36:19 +02:00
frequency
gyro iio: hid: fix the retval in gyro_3d_capture_sample 2023-02-09 11:26:42 +01:00
health iio: health: afe4404: Fix oob read in afe4404_[read|write]_raw 2022-12-08 11:28:38 +01:00
humidity iio:humidity:hts221: rearrange iio trigger get and register 2022-06-29 09:03:27 +02:00
imu iio: imu: inv_mpu6050: fix an error code problem in inv_mpu6050_read_raw 2024-01-05 15:13:32 +01:00
light iio: light: vcnl4035: fixed chip ID check 2023-06-09 10:32:28 +02:00
magnetometer iio: magnetometer: yas530: Change data type of hard_offsets to signed 2022-10-26 12:35:03 +02:00
multiplexer
orientation
position
potentiometer
potentiostat
pressure iio: pressure: ms5611: ms5611_prom_is_valid false negative bug 2023-10-19 23:05:36 +02:00
proximity iio: proximity: vl53l0x: Fix return value check of wait_for_completion_timeout 2022-06-14 18:36:05 +02:00
resolver
temperature iio: temperature: ltc2983: make bulk write buffer DMA-safe 2022-12-31 13:14:29 +01:00
test
trigger iio: trigger: sysfs: fix possible memory leak in iio_sysfs_trig_init() 2022-11-26 09:24:46 +01:00
Kconfig iio: add addac subdirectory 2023-08-26 14:23:26 +02:00
Makefile iio: add addac subdirectory 2023-08-26 14:23:26 +02:00
TODO
iio_core.h
iio_core_trigger.h
industrialio-buffer.c
industrialio-configfs.c
industrialio-core.c iio: core: introduce iio_device_{claim|release}_buffer_mode() APIs 2023-10-25 11:58:58 +02:00
industrialio-event.c iio: fix memory leak in iio_device_register_eventset() 2022-12-31 13:14:47 +01:00
industrialio-sw-device.c
industrialio-sw-trigger.c iio: core: Fix entry not deleted when iio_register_sw_trigger_type() fails 2022-12-02 17:41:08 +01:00
industrialio-trigger.c
industrialio-triggered-event.c
inkern.c iio: inkern: fix return value in devm_of_iio_channel_get_by_name() 2022-10-26 12:35:02 +02:00