]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
iio: imu: st_lsm6dsx: fix iio_chan_spec for sensors without event detection
authorFrancesco Lavra <flavra@baylibre.com>
Mon, 1 Dec 2025 10:00:10 +0000 (11:00 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 30 Jan 2026 09:27:35 +0000 (10:27 +0100)
commit7673167fac9323110973a3300637adba7d45de3a
tree57a51e6017483ee3cd6928c24e18c373bf06f683
parent85eb83694a91c89d9abe615d717c0053c3efa714
iio: imu: st_lsm6dsx: fix iio_chan_spec for sensors without event detection

commit c34e2e2d67b3bb8d5a6d09b0d6dac845cdd13fb3 upstream.

The st_lsm6dsx_acc_channels array of struct iio_chan_spec has a non-NULL
event_spec field, indicating support for IIO events. However, event
detection is not supported for all sensors, and if userspace tries to
configure accelerometer wakeup events on a sensor device that does not
support them (e.g. LSM6DS0), st_lsm6dsx_write_event() dereferences a NULL
pointer when trying to write to the wakeup register.
Define an additional struct iio_chan_spec array whose members have a NULL
event_spec field, and use this array instead of st_lsm6dsx_acc_channels for
sensors without event detection capability.

Fixes: b5969abfa8b8 ("iio: imu: st_lsm6dsx: add motion events")
Signed-off-by: Francesco Lavra <flavra@baylibre.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Acked-by: Lorenzo Bianconi <lorenzo@kernel.org>
Cc: stable@vger.kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c