]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
iio: chemical: sps30_i2c: fix buffer size in sps30_i2c_read_meas()
authorAntoniu Miclaus <antoniu.miclaus@analog.com>
Thu, 12 Feb 2026 12:46:07 +0000 (14:46 +0200)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Mon, 23 Feb 2026 08:24:38 +0000 (08:24 +0000)
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@analog.com>
Acked-by: Tomasz Duszynski <tduszyns@gmail.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/chemical/sps30_i2c.c

index f692c089d17b40f77f29729248eb20a3666ff170..c92f04990c34c23f40ee2c7230a2b26ee678a44e 100644 (file)
@@ -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)