Skip to content

Commit 159ca7f

Browse files
Silvano Sevajic23
authored andcommitted
iio: imu: st_lsm6dsx: fix possible lockup in st_lsm6dsx_read_fifo
Prevent st_lsm6dsx_read_fifo from falling in an infinite loop in case pattern_len is equal to zero and the device FIFO is not empty. Fixes: 290a6ce ("iio: imu: add support to lsm6dsx driver") Signed-off-by: Silvano Seva <s.seva@4sigma.it> Acked-by: Lorenzo Bianconi <lorenzo@kernel.org> Link: https://patch.msgid.link/20250311085030.3593-2-s.seva@4sigma.it Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
1 parent 38f67d0 commit 159ca7f

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,9 @@ int st_lsm6dsx_read_fifo(struct st_lsm6dsx_hw *hw)
392392
if (fifo_status & cpu_to_le16(ST_LSM6DSX_FIFO_EMPTY_MASK))
393393
return 0;
394394

395+
if (!pattern_len)
396+
pattern_len = ST_LSM6DSX_SAMPLE_SIZE;
397+
395398
fifo_len = (le16_to_cpu(fifo_status) & fifo_diff_mask) *
396399
ST_LSM6DSX_CHAN_SIZE;
397400
fifo_len = (fifo_len / pattern_len) * pattern_len;

0 commit comments

Comments
 (0)