* [PATCH v3 1/2] iio: imu: st_lsm6dsx: fix possible lockup in st_lsm6dsx_read_fifo
@ 2025-03-11 8:49 Silvano Seva
2025-03-11 8:49 ` [PATCH v3 2/2] iio: imu: st_lsm6dsx: fix possible lockup in st_lsm6dsx_read_tagged_fifo Silvano Seva
2025-03-15 18:36 ` [PATCH v3 1/2] iio: imu: st_lsm6dsx: fix possible lockup in st_lsm6dsx_read_fifo Jonathan Cameron
0 siblings, 2 replies; 4+ messages in thread
From: Silvano Seva @ 2025-03-11 8:49 UTC (permalink / raw)
To: jic23
Cc: a.greco, Silvano Seva, Lorenzo Bianconi, Lars-Peter Clausen,
linux-iio, linux-kernel
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: 290a6ce11d93 ("iio: imu: add support to lsm6dsx driver")
Signed-off-by: Silvano Seva <s.seva@4sigma.it>
---
Changes since v1:
* st_lsm6dsx_read_fifo: moved check for zero pattern_len before fifo_len assignment
* st_lsm6dsx_read_fifo: dropped check for zero fifo_len
* added Fixes tags in commit message
Changes since v2:
* split patch in two parts, one fixing st_lsm6dsx_read_fifo and one fixing
st_lsm6dsx_read_tagged_fifo
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c | 3 +++
1 file changed, 3 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..480a9b31065c 100644
--- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c
+++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c
@@ -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;
--
2.48.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v3 2/2] iio: imu: st_lsm6dsx: fix possible lockup in st_lsm6dsx_read_tagged_fifo
2025-03-11 8:49 [PATCH v3 1/2] iio: imu: st_lsm6dsx: fix possible lockup in st_lsm6dsx_read_fifo Silvano Seva
@ 2025-03-11 8:49 ` Silvano Seva
2025-03-15 18:36 ` [PATCH v3 1/2] iio: imu: st_lsm6dsx: fix possible lockup in st_lsm6dsx_read_fifo Jonathan Cameron
1 sibling, 0 replies; 4+ messages in thread
From: Silvano Seva @ 2025-03-11 8:49 UTC (permalink / raw)
To: jic23
Cc: a.greco, Silvano Seva, Lorenzo Bianconi, Lars-Peter Clausen,
linux-iio, linux-kernel
Prevent st_lsm6dsx_read_tagged_fifo from falling in an infinite loop in
case pattern_len is equal to zero and the device FIFO is not empty.
Fixes: 801a6e0af0c6 ("iio: imu: st_lsm6dsx: add support to LSM6DSO")
Signed-off-by: Silvano Seva <s.seva@4sigma.it>
---
Changes since v1:
* st_lsm6dsx_read_fifo: moved check for zero pattern_len before fifo_len assignment
* st_lsm6dsx_read_fifo: dropped check for zero fifo_len
* added Fixes tags in commit message
Changes since v2:
* split patch in two parts, one fixing st_lsm6dsx_read_fifo and one fixing
st_lsm6dsx_read_tagged_fifo
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c
index 480a9b31065c..8a9d2593576a 100644
--- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c
+++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c
@@ -626,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,
--
2.48.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v3 1/2] iio: imu: st_lsm6dsx: fix possible lockup in st_lsm6dsx_read_fifo
2025-03-11 8:49 [PATCH v3 1/2] iio: imu: st_lsm6dsx: fix possible lockup in st_lsm6dsx_read_fifo Silvano Seva
2025-03-11 8:49 ` [PATCH v3 2/2] iio: imu: st_lsm6dsx: fix possible lockup in st_lsm6dsx_read_tagged_fifo Silvano Seva
@ 2025-03-15 18:36 ` Jonathan Cameron
2025-03-17 9:02 ` Silvano Seva
1 sibling, 1 reply; 4+ messages in thread
From: Jonathan Cameron @ 2025-03-15 18:36 UTC (permalink / raw)
To: Silvano Seva
Cc: a.greco, Lorenzo Bianconi, Lars-Peter Clausen, linux-iio,
linux-kernel
On Tue, 11 Mar 2025 09:49:47 +0100
Silvano Seva <s.seva@4sigma.it> wrote:
> 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: 290a6ce11d93 ("iio: imu: add support to lsm6dsx driver")
> Signed-off-by: Silvano Seva <s.seva@4sigma.it>
I think you could validly have kept Lorenzo's ack given this was
just breaking the patch into two parts. I put it back and applied
these with them marked for stable to the fixes-togreg branch of iio.git
Thanks,
Jonathan
> ---
>
> Changes since v1:
> * st_lsm6dsx_read_fifo: moved check for zero pattern_len before fifo_len assignment
> * st_lsm6dsx_read_fifo: dropped check for zero fifo_len
> * added Fixes tags in commit message
>
> Changes since v2:
> * split patch in two parts, one fixing st_lsm6dsx_read_fifo and one fixing
> st_lsm6dsx_read_tagged_fifo
>
> drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c | 3 +++
> 1 file changed, 3 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..480a9b31065c 100644
> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c
> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c
> @@ -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;
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v3 1/2] iio: imu: st_lsm6dsx: fix possible lockup in st_lsm6dsx_read_fifo
2025-03-15 18:36 ` [PATCH v3 1/2] iio: imu: st_lsm6dsx: fix possible lockup in st_lsm6dsx_read_fifo Jonathan Cameron
@ 2025-03-17 9:02 ` Silvano Seva
0 siblings, 0 replies; 4+ messages in thread
From: Silvano Seva @ 2025-03-17 9:02 UTC (permalink / raw)
To: Jonathan Cameron
Cc: a.greco, Lorenzo Bianconi, Lars-Peter Clausen, linux-iio,
linux-kernel
On Sat, Mar 15, 2025 at 7:36 PM Jonathan Cameron <jic23@kernel.org> wrote:
>
> On Tue, 11 Mar 2025 09:49:47 +0100
> Silvano Seva <s.seva@4sigma.it> wrote:
>
> > 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: 290a6ce11d93 ("iio: imu: add support to lsm6dsx driver")
> > Signed-off-by: Silvano Seva <s.seva@4sigma.it>
> I think you could validly have kept Lorenzo's ack given this was
> just breaking the patch into two parts. I put it back and applied
> these with them marked for stable to the fixes-togreg branch of iio.git
>
Yes, sorry. I mistakenly dropped the "acked-by" when splitting the patch.
Thank you,
Silvano.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-03-17 9:02 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-11 8:49 [PATCH v3 1/2] iio: imu: st_lsm6dsx: fix possible lockup in st_lsm6dsx_read_fifo Silvano Seva
2025-03-11 8:49 ` [PATCH v3 2/2] iio: imu: st_lsm6dsx: fix possible lockup in st_lsm6dsx_read_tagged_fifo Silvano Seva
2025-03-15 18:36 ` [PATCH v3 1/2] iio: imu: st_lsm6dsx: fix possible lockup in st_lsm6dsx_read_fifo Jonathan Cameron
2025-03-17 9:02 ` Silvano Seva
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox