Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1407482 > unrolled thread

[PATCH] hwrng: stm32: fix maybe uninitialized variable warning

Started byMaxime Coquelin <mcoquelin.stm32@gmail.com>
First post2016-05-26 11:40 +0200
Last post2016-05-27 15:50 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] hwrng: stm32: fix maybe uninitialized variable warning Maxime Coquelin <mcoquelin.stm32@gmail.com> - 2016-05-26 11:40 +0200
    Re: [PATCH] hwrng: stm32: fix maybe uninitialized variable warning Daniel Thompson <daniel.thompson@linaro.org> - 2016-05-27 15:50 +0200

#1407482 — [PATCH] hwrng: stm32: fix maybe uninitialized variable warning

FromMaxime Coquelin <mcoquelin.stm32@gmail.com>
Date2016-05-26 11:40 +0200
Subject[PATCH] hwrng: stm32: fix maybe uninitialized variable warning
Message-ID<rCZVM-4Fq-15@gated-at.bofh.it>
This patch fixes the following warning:
drivers/char/hw_random/stm32-rng.c: In function 'stm32_rng_read':
drivers/char/hw_random/stm32-rng.c:82:19: warning: 'sr' may be used
                                        uninitialized in this function

Reported-by: Sudip Mukherjee <sudip.mukherjee@codethink.co.uk>
Suggested-by: Arnd Bergmann <arnd@arndb.de>
Cc: Daniel Thompson <daniel.thompson@linaro.org>
Signed-off-by: Maxime Coquelin <mcoquelin.stm32@gmail.com>
---
 drivers/char/hw_random/stm32-rng.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/char/hw_random/stm32-rng.c b/drivers/char/hw_random/stm32-rng.c
index 92a810648bd0..63d84e6f1891 100644
--- a/drivers/char/hw_random/stm32-rng.c
+++ b/drivers/char/hw_random/stm32-rng.c
@@ -69,8 +69,12 @@ static int stm32_rng_read(struct hwrng *rng, void *data, size_t max, bool wait)
 		}
 
 		/* If error detected or data not ready... */
-		if (sr != RNG_SR_DRDY)
+		if (sr != RNG_SR_DRDY) {
+			if (WARN_ONCE(sr & (RNG_SR_SEIS | RNG_SR_CEIS),
+					"bad RNG status - %x\n", sr))
+				writel_relaxed(0, priv->base + RNG_SR);
 			break;
+		}
 
 		*(u32 *)data = readl_relaxed(priv->base + RNG_DR);
 
@@ -79,10 +83,6 @@ static int stm32_rng_read(struct hwrng *rng, void *data, size_t max, bool wait)
 		max -= sizeof(u32);
 	}
 
-	if (WARN_ONCE(sr & (RNG_SR_SEIS | RNG_SR_CEIS),
-		      "bad RNG status - %x\n", sr))
-		writel_relaxed(0, priv->base + RNG_SR);
-
 	pm_runtime_mark_last_busy((struct device *) priv->rng.priv);
 	pm_runtime_put_sync_autosuspend((struct device *) priv->rng.priv);
 
-- 
1.9.1

[toc] | [next] | [standalone]


#1408087

FromDaniel Thompson <daniel.thompson@linaro.org>
Date2016-05-27 15:50 +0200
Message-ID<rDqjg-45S-15@gated-at.bofh.it>
In reply to#1407482
On 26/05/16 10:34, Maxime Coquelin wrote:
> This patch fixes the following warning:
> drivers/char/hw_random/stm32-rng.c: In function 'stm32_rng_read':
> drivers/char/hw_random/stm32-rng.c:82:19: warning: 'sr' may be used
>                                         uninitialized in this function
>
> Reported-by: Sudip Mukherjee <sudip.mukherjee@codethink.co.uk>
> Suggested-by: Arnd Bergmann <arnd@arndb.de>
> Cc: Daniel Thompson <daniel.thompson@linaro.org>

Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>


> Signed-off-by: Maxime Coquelin <mcoquelin.stm32@gmail.com>
> ---
>  drivers/char/hw_random/stm32-rng.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/char/hw_random/stm32-rng.c b/drivers/char/hw_random/stm32-rng.c
> index 92a810648bd0..63d84e6f1891 100644
> --- a/drivers/char/hw_random/stm32-rng.c
> +++ b/drivers/char/hw_random/stm32-rng.c
> @@ -69,8 +69,12 @@ static int stm32_rng_read(struct hwrng *rng, void *data, size_t max, bool wait)
>  		}
>
>  		/* If error detected or data not ready... */
> -		if (sr != RNG_SR_DRDY)
> +		if (sr != RNG_SR_DRDY) {
> +			if (WARN_ONCE(sr & (RNG_SR_SEIS | RNG_SR_CEIS),
> +					"bad RNG status - %x\n", sr))
> +				writel_relaxed(0, priv->base + RNG_SR);
>  			break;
> +		}
>
>  		*(u32 *)data = readl_relaxed(priv->base + RNG_DR);
>
> @@ -79,10 +83,6 @@ static int stm32_rng_read(struct hwrng *rng, void *data, size_t max, bool wait)
>  		max -= sizeof(u32);
>  	}
>
> -	if (WARN_ONCE(sr & (RNG_SR_SEIS | RNG_SR_CEIS),
> -		      "bad RNG status - %x\n", sr))
> -		writel_relaxed(0, priv->base + RNG_SR);
> -
>  	pm_runtime_mark_last_busy((struct device *) priv->rng.priv);
>  	pm_runtime_put_sync_autosuspend((struct device *) priv->rng.priv);
>
>

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web