From: Jonathan Cameron <jic23@kernel.org>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Andrea Merello <andrea.merello@iit.it>,
Lars-Peter Clausen <lars@metafoo.de>,
linux-iio@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] iio: imu: bno055: uninitialized variable bug in bno055_trigger_handler()
Date: Sat, 15 Oct 2022 17:33:59 +0100 [thread overview]
Message-ID: <20221015173359.20c7928e@jic23-huawei> (raw)
In-Reply-To: <Y0kuaO9PQkSQja+A@kili>
On Fri, 14 Oct 2022 12:39:52 +0300
Dan Carpenter <dan.carpenter@oracle.com> wrote:
> This bug is basically harmless, although it will trigger a runtime warning
> if you use KMSan. On the first iteration through the loop, the
> "best_delta" variable is uninitialized so re-order the condition to
> prevent reading uninitialized memory.
>
> Fixes: 4aefe1c2bd0c ("iio: imu: add Bosch Sensortec BNO055 core driver")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
You reported this a while back along with a second issue (false positive)
with hwval.
I posted a patch fixing both
https://lore.kernel.org/linux-iio/20221002145324.3776484-1-jic23@kernel.org/
I don't really care which patch goes in, but curious to reasoning to not also
deal with the hwval warning here?
Jonathan
> ---
> drivers/iio/imu/bno055/bno055.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/iio/imu/bno055/bno055.c b/drivers/iio/imu/bno055/bno055.c
> index 307557a609e3..52744dd98e65 100644
> --- a/drivers/iio/imu/bno055/bno055.c
> +++ b/drivers/iio/imu/bno055/bno055.c
> @@ -632,7 +632,7 @@ static int bno055_set_regmask(struct bno055_priv *priv, int val, int val2,
> return -EINVAL;
> }
> delta = abs(tbl_val - req_val);
> - if (delta < best_delta || first) {
> + if (first || delta < best_delta) {
> best_delta = delta;
> hwval = i;
> first = false;
next prev parent reply other threads:[~2022-10-15 16:33 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-14 9:39 [PATCH] iio: imu: bno055: uninitialized variable bug in bno055_trigger_handler() Dan Carpenter
2022-10-14 10:38 ` Sa, Nuno
2022-10-15 16:33 ` Jonathan Cameron [this message]
2022-10-29 15:39 ` Jonathan Cameron
2022-11-07 13:55 ` Dan Carpenter
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=20221015173359.20c7928e@jic23-huawei \
--to=jic23@kernel.org \
--cc=andrea.merello@iit.it \
--cc=dan.carpenter@oracle.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.