iio: imu: st_lsm6dsx: fix possible lockup during FIFO read
Lorenzo Bianconi
Acked-byI guess it was v3 in this case :)
Acked-by Lorenzo Bianconi <[email protected]>
Regards,
Lorenzo
Quoted 44 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.Fixes 290a6ce11d93 ("iio: imu: add support to lsm6dsx driver")Fixes 801a6e0af0c6 ("iio: imu: st_lsm6dsx: add support to LSM6DSO")Signed-off-by Silvano Seva <[email protected]>---
Changes since v1:
*st_lsm6dsx_read_fifo: moved check for zeropattern_lenbeforefifo_lenassignment
*st_lsm6dsx_read_fifo: dropped check for zerofifo_len
* added Fixes tags in commit messagedrivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c | 6 ++++++ 1 file changed, 6 insertions(+)drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c +6
-0@@ -392,6 +392,9 @@ int st_lsm6dsx_read_fifo(struct st_lsm6dsx_hw *hw)if (fifo_status &cpu_to_le16 (ST_LSM6DSX_FIFO_EMPTY_MASK ))return 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;@@ -623,6 +626,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
Quoted 8 lines · Lorenzo Bianconi
I guess it was v3 in this case :)
Acked-by Lorenzo Bianconi <[email protected]>Regards,
Lorenzo
Yes, sorry. Is the first patch I submit and I still need to get used to some some parts of the workflow.
Thank you,
Silvano.