]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
iio: accel: adxl380: Avoid reading more entries than present in FIFO
authorFrancesco Lavra <flavra@baylibre.com>
Mon, 19 Jan 2026 10:23:16 +0000 (11:23 +0100)
committerSasha Levin <sashal@kernel.org>
Wed, 4 Mar 2026 12:21:13 +0000 (07:21 -0500)
[ Upstream commit c1b14015224cfcccd5356333763f2f4f401bd810 ]

The interrupt handler reads FIFO entries in batches of N samples, where N
is the number of scan elements that have been enabled. However, the sensor
fills the FIFO one sample at a time, even when more than one channel is
enabled. Therefore,the number of entries reported by the FIFO status
registers may not be a multiple of N; if this number is not a multiple, the
number of entries read from the FIFO may exceed the number of entries
actually present.

To fix the above issue, round down the number of FIFO entries read from the
status registers so that it is always a multiple of N.

Fixes: df36de13677a ("iio: accel: add ADXL380 driver")
Signed-off-by: Francesco Lavra <flavra@baylibre.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/iio/accel/adxl380.c

index 6d82873357cb8ddb41ff84169c758ea476137d67..217c5ae56d23a5c5d7d178aa45839a1dffa45f44 100644 (file)
@@ -977,6 +977,7 @@ static irqreturn_t adxl380_irq_handler(int irq, void  *p)
        if (ret)
                return IRQ_HANDLED;
 
+       fifo_entries = rounddown(fifo_entries, st->fifo_set_size);
        for (i = 0; i < fifo_entries; i += st->fifo_set_size) {
                ret = regmap_noinc_read(st->regmap, ADXL380_FIFO_DATA,
                                        &st->fifo_buf[i],