Skip to content

Commit c3914ce

Browse files
amiclausjic23
authored andcommitted
iio: chemical: sps30_serial: fix buffer size in sps30_serial_read_meas()
sizeof(num) evaluates to sizeof(size_t) which is 8 bytes on 64-bit, but the buffer elements are only 4 bytes. The same function already uses sizeof(*meas) on line 312, making the mismatch evident. Use sizeof(*meas) consistently. Fixes: b2e171f ("iio: sps30: add support for serial interface") 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>
1 parent 216345f commit c3914ce

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

drivers/iio/chemical/sps30_serial.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ static int sps30_serial_read_meas(struct sps30_state *state, __be32 *meas, size_
303303
if (msleep_interruptible(1000))
304304
return -EINTR;
305305

306-
ret = sps30_serial_command(state, SPS30_SERIAL_READ_MEAS, NULL, 0, meas, num * sizeof(num));
306+
ret = sps30_serial_command(state, SPS30_SERIAL_READ_MEAS, NULL, 0, meas, num * sizeof(*meas));
307307
if (ret < 0)
308308
return ret;
309309
/* if measurements aren't ready sensor returns empty frame */

0 commit comments

Comments
 (0)