Re: [PATCH 1/2] iio: chemical: sps30_i2c: fix buffer size in sps30_i2c_read_meas()
From: Tomasz Duszyński
Date: Mon Feb 16 2026 - 01:07:08 EST
On Thu, Feb 12, 2026 at 1:46 PM Antoniu Miclaus
<antoniu.miclaus@xxxxxxxxxx> wrote:
>
> sizeof(num) evaluates to sizeof(size_t) (8 bytes on 64-bit) instead
> of the intended __be32 element size (4 bytes). Use sizeof(*meas) to
> correctly match the buffer element type.
>
> Fixes: 8f3f13085278 ("iio: sps30: separate core and interface specific code")
> Signed-off-by: Antoniu Miclaus <antoniu.miclaus@xxxxxxxxxx>
> ---
> drivers/iio/chemical/sps30_i2c.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/iio/chemical/sps30_i2c.c b/drivers/iio/chemical/sps30_i2c.c
> index f692c089d17b..c92f04990c34 100644
> --- a/drivers/iio/chemical/sps30_i2c.c
> +++ b/drivers/iio/chemical/sps30_i2c.c
> @@ -171,7 +171,7 @@ static int sps30_i2c_read_meas(struct sps30_state *state, __be32 *meas, size_t n
> if (!sps30_i2c_meas_ready(state))
> return -ETIMEDOUT;
>
> - return sps30_i2c_command(state, SPS30_I2C_READ_MEAS, NULL, 0, meas, sizeof(num) * num);
> + return sps30_i2c_command(state, SPS30_I2C_READ_MEAS, NULL, 0, meas, sizeof(*meas) * num);
> }
>
> static int sps30_i2c_clean_fan(struct sps30_state *state)
> --
> 2.43.0
>
Acked-by: Tomasz Duszynski <tduszyns@xxxxxxxxx>