Commit c3914ce1 authored by Antoniu Miclaus's avatar Antoniu Miclaus Committed by Jonathan Cameron
Browse files

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: b2e171f5 ("iio: sps30: add support for serial interface")
Signed-off-by: default avatarAntoniu Miclaus <antoniu.miclaus@analog.com>
Acked-by: default avatarTomasz Duszynski <tduszyns@gmail.com>
Reviewed-by: default avatarAndy Shevchenko <andriy.shevchenko@intel.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent 216345f9
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -303,7 +303,7 @@ static int sps30_serial_read_meas(struct sps30_state *state, __be32 *meas, size_
	if (msleep_interruptible(1000))
		return -EINTR;

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