linux/drivers/iio
Fan Wu 9ee8306121 iio: adc: ad_sigma_delta: fix use-after-free on unbind
ad_sd_buffer_postenable() allocates sigma_delta->samples_buf with
devm_krealloc() at runtime, so its devres entry sits after all
probe-time entries of the driver. devm resources are released in
reverse allocation order, which means unbind frees samples_buf before
iio_device_unregister() disables the buffers and detaches the trigger
pollfunc. The data ready IRQ is still enabled at that point, so
ad_sd_trigger_handler() can still run and memcpy() incoming samples
into the freed samples_buf.

Fix this by preallocating the buffer in
devm_ad_sd_setup_buffer_and_trigger(), before the triggered buffer and
the IRQ are set up, so it is freed only after iio_device_unregister()
has drained the trigger handler via free_irq(). Size it for the worst
case of all sequencer slots being active; ad_sd_validate_scan_mask()
already caps the number of active channels at num_slots.

This issue was found by an in-house static analysis tool.

Fixes: 8bea9af887 ("iio: adc: ad_sigma_delta: Add sequencer support")
Cc: stable@vger.kernel.org
Co-developed-by: Song Li <songl@zju.edu.cn>
Signed-off-by: Song Li <songl@zju.edu.cn>
Signed-off-by: Fan Wu <fanwu01@zju.edu.cn>
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
2026-09-30 18:59:56 +01:00
..
accel iio: accel: kxcjk-1013: reject duplicate event disable 2026-09-30 18:59:56 +01:00
adc iio: adc: ad_sigma_delta: fix use-after-free on unbind 2026-09-30 18:59:56 +01:00
addac Char/Misc/IIO/etc driver update for 7.3-rc1 2026-08-25 09:38:50 -07:00
afe Linux 7.2-rc2 2026-07-06 16:59:47 +01:00
amplifiers Linux 7.2-rc2 2026-07-06 16:59:47 +01:00
buffer IIO: 1st set of fixes for the 7.3 cycle. 2026-09-11 11:52:17 +02:00
cdc iio: cdc: ad7150: fix OF matching and publish module aliases 2026-09-30 18:59:55 +01:00
chemical IIO new device support, features, cleanup for 7.3 2026-08-19 09:45:01 +02:00
common iio: inv_sensors: fix estimated value larger than interrupt timestamp 2026-08-31 02:17:56 +01:00
dac iio: dac: mcp47a1: Allow full-scale output 2026-09-06 22:48:38 +01:00
dummy Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
filter Linux 7.2-rc2 2026-07-06 16:59:47 +01:00
flow iio: flow: add Sensirion SLF3S liquid flow sensor driver 2026-08-05 00:03:28 +01:00
frequency iio: frequency: admv1013: fix wrong channel field used in admv1013_read_raw() 2026-08-31 00:52:42 +01:00
gyro iio: gyro: adis16136: fix unprotected debugfs reads 2026-08-31 00:52:42 +01:00
health iio: health: max30102: fix NULL dereference in interrupt handler 2026-08-31 00:52:39 +01:00
humidity iio: humidity: Remove redundant dev_err()/dev_err_probe() 2026-07-27 22:13:07 +01:00
imu iio: imu: inv_icm42607: restore runtime PM on system resume errors 2026-09-30 18:59:55 +01:00
light iio: light: rohm-bu27034: Fix infinite delay on error 2026-09-06 22:33:15 +01:00
magnetometer iio: magnetometer: ak8974: remove conditional return with no effect 2026-08-03 22:32:32 +01:00
multiplexer Linux 7.2-rc2 2026-07-06 16:59:47 +01:00
orientation IIO new device support, features, cleanup for 7.3 2026-08-19 09:45:01 +02:00
position iio: hid-sensors: align function parenthesis for readability 2026-07-07 03:12:50 +01:00
potentiometer Linux 7.2-rc2 2026-07-06 16:59:47 +01:00
potentiostat Linux 7.2-rc2 2026-07-06 16:59:47 +01:00
pressure iio: pressure: rohm-bm1390: Return error when read fails 2026-08-31 00:52:41 +01:00
proximity iio: proximity: isl29501: Fix return type of isl29501_register_write 2026-09-30 18:59:55 +01:00
resolver iio: resolver: ad2s1200: use dev_err_probe() 2026-07-18 23:50:29 +01:00
temperature IIO new device support, features, cleanup for 7.3 2026-08-19 09:45:01 +02:00
test iio: test: iio-test-format: add test case for decimal format 2026-06-30 00:15:52 +01:00
trigger Replace <linux/mod_devicetable.h> by more specific <linux/device-id/*.h> (c files) 2026-07-03 07:38:17 +02:00
iio_core_trigger.h iio: core: trigger: correct CONFIG_IIO_TRIGGER macro name in #endif comment 2026-06-29 19:05:37 +01:00
iio_core.h
industrialio-acpi.c
industrialio-backend.c iio: backend: fix typos in comments 2026-07-02 17:56:34 +01:00
industrialio-buffer.c iio: buffer: serialize buffer teardown with mode claims 2026-09-30 18:59:56 +01:00
industrialio-configfs.c
industrialio-core.c iio: core: add IIO_VAL_DECIMAL64_FEMTO format type 2026-08-05 00:03:28 +01:00
industrialio-event.c iio: event: Fix event FIFO reset race 2026-07-08 15:47:34 +01:00
industrialio-gts-helper.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
industrialio-sw-device.c iio: core: Constify struct configfs_item_operations and configfs_group_operations 2025-12-31 17:59:26 +00:00
industrialio-sw-trigger.c iio: core: Constify struct configfs_item_operations and configfs_group_operations 2025-12-31 17:59:26 +00:00
industrialio-trigger.c iio: trigger: cancel reenable_work before freeing trigger 2026-08-31 00:52:42 +01:00
industrialio-triggered-event.c
inkern.c treewide: refresh kmalloc_obj() conversions 2026-09-04 21:37:00 -07:00
Kconfig iio: flow: add Sensirion SLF3S liquid flow sensor driver 2026-08-05 00:03:28 +01:00
Makefile iio: flow: add Sensirion SLF3S liquid flow sensor driver 2026-08-05 00:03:28 +01:00
TODO iio: todo: fix typo and refine resource management items 2026-06-29 19:05:38 +01:00