Commit 20eb1fae authored by Dan Carpenter's avatar Dan Carpenter Committed by Jonathan Cameron
Browse files

iio: chemical: bme680: Fix uninitialized variable in __bme680_read_raw()



The bme680_read_temp() function takes a pointer to s16 but we're passing
an int pointer to it.  This will not work on big endian systems and it
also means that the other 16 bits are uninitialized.

Pass an s16 type variable.

Fixes: f51171ce ("iio: chemical: bme680: Add SCALE and RAW channels")
Signed-off-by: default avatarDan Carpenter <dan.carpenter@linaro.org>
Acked-by: default avatarVasileios Amoiridis <vassilisamir@gmail.com>
Link: https://patch.msgid.link/4addb68c-853a-49fc-8d40-739e78db5fa1@stanley.mountain


Cc: <stable@vger.kernel.org>
Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent ab09c6cf
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -874,11 +874,11 @@ static int bme680_read_raw(struct iio_dev *indio_dev,
	case IIO_CHAN_INFO_RAW:
		switch (chan->type) {
		case IIO_TEMP:
			ret = bme680_read_temp(data, (s16 *)&chan_val);
			ret = bme680_read_temp(data, &temp_chan_val);
			if (ret)
				return ret;

			*val = chan_val;
			*val = temp_chan_val;
			return IIO_VAL_INT;
		case IIO_PRESSURE:
			ret = bme680_read_press(data, &chan_val);