linux/drivers/iio/proximity
Sven Van Asbroeck 11362b7a43 iio: proximity: as3935: fix use-after-free on device remove
This driver's probe() uses a mix of devm_ and non-devm_ functions. This
means that the remove order will not be the exact opposite of the probe
order.

Remove order:
1. remove() executes:
	iio_device_unregister
	iio_triggered_buffer_cleanup
	iio_trigger_unregister
	(A)
2. core frees devm resources in reverse order:
	free_irq
	iio_trigger_free
	iio_device_free

In (A) the trigger has been unregistered, but the irq handler is still
registered and active, so the trigger may still be touched via
interrupt -> as3935_event_work. This is a potential use-after-unregister.

Given that the delayed work is never canceled explicitly, it may run even
after iio_device_free. This is a potential use-after-free.

Solution: convert all probe functions to their devm_ equivalents.
Add a devm callback, called by the core on remove right after irq_free,
which explicitly cancels the delayed work. This will guarantee that all
resources are freed in the correct order.

As an added bonus, some boilerplate code can be removed.

Signed-off-by: Sven Van Asbroeck <TheSven73@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-04-04 20:19:56 +01:00
..
as3935.c iio: proximity: as3935: fix use-after-free on device remove 2019-04-04 20:19:56 +01:00
isl29501.c iio: light: isl29501: Simplify code to kill compiler warning 2018-09-02 09:56:49 +01:00
Kconfig iio: proximity: Add driver support for ST's VL53L0X ToF ranging sensor. 2018-09-22 16:42:56 +01:00
Makefile iio: proximity: Add driver support for ST's VL53L0X ToF ranging sensor. 2018-09-22 16:42:56 +01:00
pulsedlight-lidar-lite-v2.c iio: add SPDX identifier for various drivers 2018-02-18 11:55:19 +00:00
rfd77402.c iio: proximity: Add rfd77402 driver 2017-10-14 18:28:51 +01:00
srf04.c iio:proximity: drop assign iio_info.driver_module and iio_trigger_ops.owner 2017-08-22 22:14:51 +01:00
srf08.c iio:proximity: drop assign iio_info.driver_module and iio_trigger_ops.owner 2017-08-22 22:14:51 +01:00
sx9500.c iio: proximity: sx9500: Add GPIO ACPI mapping table 2018-03-03 15:11:27 +00:00
vl53l0x-i2c.c iio: proximity: Add driver support for ST's VL53L0X ToF ranging sensor. 2018-09-22 16:42:56 +01:00