From: Jonathan Cameron <jic23@kernel.org>
To: Mikhail Lobanov <m.lobanov@rosalinux.ru>
Cc: Dan Robertson <dan@dlrobertson.com>,
Lars-Peter Clausen <lars@metafoo.de>,
Jagath Jog J <jagathjog1996@gmail.com>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
lvc-project@linuxtesting.org
Subject: Re: [PATCH] iio: accel: bma400: Fix uninitialized variable field_value in tap event handling.
Date: Sat, 14 Sep 2024 14:58:54 +0100 [thread overview]
Message-ID: <20240914145854.21569134@jic23-huawei> (raw)
In-Reply-To: <20240910083624.27224-1-m.lobanov@rosalinux.ru>
On Tue, 10 Sep 2024 04:36:20 -0400
Mikhail Lobanov <m.lobanov@rosalinux.ru> wrote:
> In the current implementation, the local variable field_value is used
> without prior initialization, which may lead to reading uninitialized
> memory. Specifically, in the macro set_mask_bits, the initial
> (potentially uninitialized) value of the buffer is copied into old__,
> and a mask is applied to calculate new__. A similar issue was resolved in
> commit 6ee2a7058fea ("iio: accel: bma400: Fix smatch warning based on use
> of unintialized value.").
>
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
>
> Fixes: 961db2da159d ("iio: accel: bma400: Add support for single and double tap events")
> Signed-off-by: Mikhail Lobanov <m.lobanov@rosalinux.ru>
Ok. It's not a bug as such because ultimately the bits that aren't set are masked out
but it is non obvious. So applied to the fixes-togreg branch of iio.git.
Thanks,
Jonathan
> ---
> drivers/iio/accel/bma400_core.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/iio/accel/bma400_core.c b/drivers/iio/accel/bma400_core.c
> index e90e2f01550a..04083b7395ab 100644
> --- a/drivers/iio/accel/bma400_core.c
> +++ b/drivers/iio/accel/bma400_core.c
> @@ -1219,7 +1219,8 @@ static int bma400_activity_event_en(struct bma400_data *data,
> static int bma400_tap_event_en(struct bma400_data *data,
> enum iio_event_direction dir, int state)
> {
> - unsigned int mask, field_value;
> + unsigned int mask;
> + unsigned int field_value = 0;
> int ret;
>
> /*
prev parent reply other threads:[~2024-09-14 13:59 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-10 8:36 Mikhail Lobanov
2024-09-14 13:58 ` Jonathan Cameron [this message]
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=20240914145854.21569134@jic23-huawei \
--to=jic23@kernel.org \
--cc=dan@dlrobertson.com \
--cc=jagathjog1996@gmail.com \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lvc-project@linuxtesting.org \
--cc=m.lobanov@rosalinux.ru \
/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
all inboxes | Powered by JetHome®