From: Vasileios Amoiridis <vassilisamir@gmail.com>
To: Dan Carpenter <dan.carpenter@linaro.org>
Cc: Jonathan Cameron <jic23@kernel.org>,
Lars-Peter Clausen <lars@metafoo.de>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] iio: chemical: bme680: Fix uninitialized variable in __bme680_read_raw()
Date: Wed, 8 Jan 2025 22:29:40 +0100 [thread overview]
Message-ID: <Z37uRAl18atKgVz0@vamoirid-laptop> (raw)
In-Reply-To: <4addb68c-853a-49fc-8d40-739e78db5fa1@stanley.mountain>
On Wed, Jan 08, 2025 at 12:37:22PM +0300, Dan Carpenter wrote:
> 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: f51171ce2236 ("iio: chemical: bme680: Add SCALE and RAW channels")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
> drivers/iio/chemical/bme680_core.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/iio/chemical/bme680_core.c b/drivers/iio/chemical/bme680_core.c
> index 26eb0fa77a43..9d73fd2cf52c 100644
> --- a/drivers/iio/chemical/bme680_core.c
> +++ b/drivers/iio/chemical/bme680_core.c
> @@ -879,11 +879,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);
> --
> 2.45.2
>
Acked-by: Vasileios Amoiridis <vassilisamir@gmail.com>
Hi Dan,
I had already applied this for IIO_CHAN_INFO_PROCESSED but not for the
IIO_CHAN_INFO_RAW channel... Very good that you spotted it!
Cheers,
Vasilis
next prev parent reply other threads:[~2025-01-08 21:29 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-08 9:37 [PATCH] iio: chemical: bme680: Fix uninitialized variable in __bme680_read_raw() Dan Carpenter
2025-01-08 21:29 ` Vasileios Amoiridis [this message]
2025-01-12 13:13 ` Jonathan Cameron
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Z37uRAl18atKgVz0@vamoirid-laptop \
--to=vassilisamir@gmail.com \
--cc=dan.carpenter@linaro.org \
--cc=jic23@kernel.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox