[<prev] [next>] [day] [month] [year] [list]
Message-ID: <Z87q67AvUgd8yu7S@lore-desk>
Date: Mon, 10 Mar 2025 14:36:43 +0100
From: Lorenzo Bianconi <lorenzo@...nel.org>
To: Silvano Seva <s.seva@...gma.it>
Cc: a.greco@...gma.it, Jonathan Cameron <jic23@...nel.org>,
Lars-Peter Clausen <lars@...afoo.de>, linux-iio@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] 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: <20250310132508.24660-2-s.seva@...gma.it>
> Prevent st_lsm6dsx_read_fifo and st_lsm6dsx_read_tagged_fifo functions
> from falling in an infinite loop in case pattern_len is equal to zero and
> the device FIFO is not empty.
>
> Signed-off-by: Silvano Seva <s.seva@...gma.it>
> ---
> drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c
> index 0a7cd8c1aa33..39a7e15ae9ae 100644
> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c
> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c
> @@ -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))
> 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;
> + if (!fifo_len)
> + return 0;
this is not needed, please drop it.
Regards,
Lorenzo
>
> acc_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,
> --
> 2.48.1
>
Download attachment "signature.asc" of type "application/pgp-signature" (229 bytes)
Powered by blists - more mailing lists