Check read_fifo pointer before using it since we can't assume it is always set adding new sensors Signed-off-by: Lorenzo Bianconi <lorenzo@xxxxxxxxxx> --- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c index 21c2aad8c56a..f80ce77a4154 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c @@ -588,6 +588,9 @@ int st_lsm6dsx_flush_fifo(struct st_lsm6dsx_hw *hw) { int err; + if (!hw->settings->fifo_ops.read_fifo) + return -ENOTSUPP; + mutex_lock(&hw->fifo_lock); hw->settings->fifo_ops.read_fifo(hw); @@ -662,6 +665,9 @@ static irqreturn_t st_lsm6dsx_handler_thread(int irq, void *private) struct st_lsm6dsx_hw *hw = private; int count; + if (!hw->settings->fifo_ops.read_fifo) + return IRQ_NONE; + mutex_lock(&hw->fifo_lock); count = hw->settings->fifo_ops.read_fifo(hw); mutex_unlock(&hw->fifo_lock); -- 2.21.0