public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH 1/4] crypto: sunxi - don't print uninitialized data
@ 2016-01-25 16:53 Arnd Bergmann
  2016-01-25 16:56 ` Arnd Bergmann
  2016-01-26 10:44 ` Herbert Xu
  0 siblings, 2 replies; 3+ messages in thread
From: Arnd Bergmann @ 2016-01-25 16:53 UTC (permalink / raw)
  To: linux-arm-kernel

gcc correctly warns that the printk output contains a variable that
is not initialized in some cases:

drivers/crypto/sunxi-ss/sun4i-ss-cipher.c: In function 'sun4i_ss_cipher_poll':
drivers/crypto/sunxi-ss/sun4i-ss-cipher.c:254:76: warning: 'todo' may be used uninitialized in this function [-Wmaybe-uninitialized]
drivers/crypto/sunxi-ss/sun4i-ss-cipher.c:144:15: note: 'todo' was declared here

This adds an explicit initialization to zero in the exact case where it
was missing, to avoid leaking stack data to the console and to shut up
that warning.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/crypto/sunxi-ss/sun4i-ss-cipher.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c b/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c
index a19ee127edca..db52ae16c147 100644
--- a/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c
+++ b/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c
@@ -246,6 +246,8 @@ static int sun4i_ss_cipher_poll(struct ablkcipher_request *areq)
 				sg_miter_next(&mi);
 				oi = 0;
 			}
+		} else {
+			todo = 0;
 		}
 
 		spaces = readl(ss->base + SS_FCSR);
-- 
2.7.0

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

* [PATCH 1/4] crypto: sunxi - don't print uninitialized data
  2016-01-25 16:53 [PATCH 1/4] crypto: sunxi - don't print uninitialized data Arnd Bergmann
@ 2016-01-25 16:56 ` Arnd Bergmann
  2016-01-26 10:44 ` Herbert Xu
  1 sibling, 0 replies; 3+ messages in thread
From: Arnd Bergmann @ 2016-01-25 16:56 UTC (permalink / raw)
  To: linux-arm-kernel

On Monday 25 January 2016 17:53:48 Arnd Bergmann wrote:
> gcc correctly warns that the printk output contains a variable that
> is not initialized in some cases:
> 
> drivers/crypto/sunxi-ss/sun4i-ss-cipher.c: In function 'sun4i_ss_cipher_poll':
> drivers/crypto/sunxi-ss/sun4i-ss-cipher.c:254:76: warning: 'todo' may be used uninitialized in this function [-Wmaybe-uninitialized]
> drivers/crypto/sunxi-ss/sun4i-ss-cipher.c:144:15: note: 'todo' was declared here
> 
> This adds an explicit initialization to zero in the exact case where it
> was missing, to avoid leaking stack data to the console and to shut up
> that warning.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> 


Sorry for the broken ordering and missing cover letter. 
I just submitted three crypto patches:

[PATCH 1/4] crypto: sunxi - don't print uninitialized data
[PATCH] crypto: hash - select CRYPTO_HASH where needed
[PATCH 1/2] crypto: jitterentropy - always select CRYPTO_RNG

These address independent build issues, and there is no ordering between
them. None of them are important, so please queue them up for 4.6.

	Arnd

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

* [PATCH 1/4] crypto: sunxi - don't print uninitialized data
  2016-01-25 16:53 [PATCH 1/4] crypto: sunxi - don't print uninitialized data Arnd Bergmann
  2016-01-25 16:56 ` Arnd Bergmann
@ 2016-01-26 10:44 ` Herbert Xu
  1 sibling, 0 replies; 3+ messages in thread
From: Herbert Xu @ 2016-01-26 10:44 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Jan 25, 2016 at 05:53:48PM +0100, Arnd Bergmann wrote:
> gcc correctly warns that the printk output contains a variable that
> is not initialized in some cases:
> 
> drivers/crypto/sunxi-ss/sun4i-ss-cipher.c: In function 'sun4i_ss_cipher_poll':
> drivers/crypto/sunxi-ss/sun4i-ss-cipher.c:254:76: warning: 'todo' may be used uninitialized in this function [-Wmaybe-uninitialized]
> drivers/crypto/sunxi-ss/sun4i-ss-cipher.c:144:15: note: 'todo' was declared here
> 
> This adds an explicit initialization to zero in the exact case where it
> was missing, to avoid leaking stack data to the console and to shut up
> that warning.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

This is actually a bogus warning because todo is always initialised
but gcc can't see that because it's behind multiple conditionals.

It would be great if we can restructure the code so that gcc can see
this while at the same time also improving the readability of the
loop.

Otherwise just initialise it at the top or use uninitialised_var.

Thanks,
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

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

end of thread, other threads:[~2016-01-26 10:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-25 16:53 [PATCH 1/4] crypto: sunxi - don't print uninitialized data Arnd Bergmann
2016-01-25 16:56 ` Arnd Bergmann
2016-01-26 10:44 ` Herbert Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox