Re: [PATCH v2 3/7] iio: accel: adxl313: Reject sub-base ODR codes in adxl313_read_raw()

From: Jonathan Cameron

Date: Sat Nov 28 2026 - 18:14:43 EST


On Mon, 23 Nov 2026 07:50:29 +0000
Lee Jones <lee@xxxxxxxxxx> wrote:

> When reading IIO_CHAN_INFO_SAMP_FREQ, adxl313_read_raw() extracts the
> 4-bit rate field (0..15) from ADXL313_REG_BW_RATE and subtracts
> ADXL313_RATE_BASE (6) to index adxl313_odr_freqs[].
>
> ADXL312 and ADXL314 support sub-6.25 Hz rate codes 0..5 and do not
> perform a soft reset during setup, and debugfs register writes or a
> faulty bus read can likewise yield codes below ADXL313_RATE_BASE. When
> that happens, subtracting ADXL313_RATE_BASE produces a negative index
> and reads before the start of adxl313_odr_freqs[].
>
> Return -ERANGE if the rate field is below ADXL313_RATE_BASE.
>
> Fixes: 636d44633039 ("iio: accel: Add driver support for ADXL313")
> Closes: https://sashiko.dev/#/bug/linux-d6086ee0-d732-43b6-b8ac-24e5bf86a9f8
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Lee Jones <lee@xxxxxxxxxx>
Applied to the fixes-togreg branch of iio.git.

Thanks,

Jonathan