linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH][next] rtc: rzn1: Fix uninitialized variable val
@ 2022-05-19 10:06 Colin Ian King
  2022-05-19 12:12 ` Miquel Raynal
  0 siblings, 1 reply; 2+ messages in thread
From: Colin Ian King @ 2022-05-19 10:06 UTC (permalink / raw)
  To: Miquel Raynal, Alessandro Zummo, Alexandre Belloni,
	Michel Pollet, linux-rtc, linux-renesas-soc
  Cc: kernel-janitors, linux-kernel

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;
 	int ret;
 
 	/*
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH][next] rtc: rzn1: Fix uninitialized variable val
  2022-05-19 10:06 [PATCH][next] rtc: rzn1: Fix uninitialized variable val Colin Ian King
@ 2022-05-19 12:12 ` Miquel Raynal
  0 siblings, 0 replies; 2+ messages in thread
From: Miquel Raynal @ 2022-05-19 12:12 UTC (permalink / raw)
  To: Colin Ian King
  Cc: Alessandro Zummo, Alexandre Belloni, Michel Pollet, linux-rtc,
	linux-renesas-soc, kernel-janitors, linux-kernel

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-05-19 12:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-19 10:06 [PATCH][next] rtc: rzn1: Fix uninitialized variable val Colin Ian King
2022-05-19 12:12 ` Miquel Raynal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).