iio: imu: st_lsm6dsx: fix possible lockup during FIFO read
I guess you missed v2 here. Moreover, can you please proper Fixes tag?
Reply-To:
In-Reply-To: <[email protected]>
Quoted 15 lines
Prevent
st_lsm6dsx_read_fifoandst_lsm6dsx_read_tagged_fifofunctions from falling in an infinite loop in casepattern_lenis equal to zero and the device FIFO is not empty.Signed-off-by Silvano Seva <[email protected]>--- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c | 8 ++++++++ 1 file changed, 8 insertions(+)drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c +0
-0@@ -392,9 +392,14 @@ int st_lsm6dsx_read_fifo(struct st_lsm6dsx_hw *hw)if (fifo_status &cpu_to_le16 (ST_LSM6DSX_FIFO_EMPTY_MASK ))
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c int st_lsm6dsx_read_fifo(struct st_lsm6dsx_hw *hw) · line 402
Quoted 10 lines
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c +5
-0return 0 ; +if (!pattern_len) + pattern_len =ST_LSM6DSX_SAMPLE_SIZE ; + fifo_len = (le16_to_cpu (fifo_status) & fifo_diff_mask) *ST_LSM6DSX_CHAN_SIZE ; fifo_len = (fifo_len / pattern_len) * pattern_len; +if (!fifo_len) +return 0 ;
this is not needed, please drop it.
Regards,
Lorenzo
Quoted 16 lines
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c +3
-0acc_sensor =iio_priv (hw->iio_devs[ST_LSM6DSX_ID_ACC ]); gyro_sensor =iio_priv (hw->iio_devs[ST_LSM6DSX_ID_GYRO ]);@@ -623,6 +628,9 @@ int st_lsm6dsx_read_tagged_fifo(struct st_lsm6dsx_hw *hw)if (!fifo_len)return 0 ; +if (!pattern_len) + pattern_len =ST_LSM6DSX_TAGGED_SAMPLE_SIZE ; +for (read_len =0 ; read_len < fifo_len; read_len += pattern_len) { err = st_lsm6dsx_read_block(hw, ST_LSM6DSX_REG_FIFO_OUT_TAG_ADDR,Signature · 1 line
2.48.1