From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Colin Ian King <colin.i.king@gmail.com>
Cc: Alessandro Zummo <a.zummo@towertech.it>,
Alexandre Belloni <alexandre.belloni@bootlin.com>,
Michel Pollet <michel.pollet@bp.renesas.com>,
linux-rtc@vger.kernel.org, linux-renesas-soc@vger.kernel.org,
kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH][next] rtc: rzn1: Fix uninitialized variable val
Date: Thu, 19 May 2022 14:12:52 +0200 [thread overview]
Message-ID: <20220519141252.7b24d522@xps-13> (raw)
In-Reply-To: <20220519100641.595608-1-colin.i.king@gmail.com>
Hi Colin,
colin.i.king@gmail.com wrote on Thu, 19 May 2022 11:06:41 +0100:
> Variable val is not being initialized and is later being read with
> a potentially garbage value. Fix this by initializing val to zero.
>
> Detected by clang scan build:
> warning: variable 'val' is uninitialized when used here [-Wuninitialized]
>
> Fixes: deeb4b5393e1 ("rtc: rzn1: Add new RTC driver")
> Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
> ---
> drivers/rtc/rtc-rzn1.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/rtc/rtc-rzn1.c b/drivers/rtc/rtc-rzn1.c
> index 980ade8c9601..0b4bf6e43464 100644
> --- a/drivers/rtc/rtc-rzn1.c
> +++ b/drivers/rtc/rtc-rzn1.c
> @@ -272,7 +272,7 @@ static int rzn1_rtc_set_offset(struct device *dev, long offset)
> struct rzn1_rtc *rtc = dev_get_drvdata(dev);
> unsigned int steps;
> int stepsh, stepsl;
> - u32 val;
> + u32 val = 0;
There are actually two variables mixed together. "val" is used both for
the readl_poll_timeout() call (where it should be a dedicated 'ctl2'
variable) and for the subu register which is written at the end. This
variable could be renamed 'subu' and initialized to 0 as you did.
Thanks,
Miquèl
prev parent reply other threads:[~2022-05-19 12:13 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-19 10:06 [PATCH][next] rtc: rzn1: Fix uninitialized variable val Colin Ian King
2022-05-19 12:12 ` Miquel Raynal [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=20220519141252.7b24d522@xps-13 \
--to=miquel.raynal@bootlin.com \
--cc=a.zummo@towertech.it \
--cc=alexandre.belloni@bootlin.com \
--cc=colin.i.king@gmail.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=linux-rtc@vger.kernel.org \
--cc=michel.pollet@bp.renesas.com \
/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