[PATCH][V2] s390/crypto: initialize ret to nbytes to avoid returning garbage value

From: Colin King
Date: Tue Sep 06 2016 - 03:26:48 EST


From: Colin Ian King <colin.king@xxxxxxxxxxxxx>

Static analysis with cppcheck detected that ret is not initialized
and hence garbage is potentially being returned in the case where
prng_data->ppnows.reseed_counter <= prng_reseed_limit.

Thanks to Martin Schwidefsky for spotting a mistake in my original
fix.

Fixes: 0177db01adf26cf9 ("s390/crypto: simplify return code handling")
Signed-off-by: Colin Ian King <colin.king@xxxxxxxxxxxxx>
---
arch/s390/crypto/prng.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/s390/crypto/prng.c b/arch/s390/crypto/prng.c
index 79e3a1f..5592df9 100644
--- a/arch/s390/crypto/prng.c
+++ b/arch/s390/crypto/prng.c
@@ -412,7 +412,7 @@ static int prng_sha512_reseed(void)

static int prng_sha512_generate(u8 *buf, size_t nbytes)
{
- int ret;
+ int ret = nbytes;

/* reseed needed ? */
if (prng_data->ppnows.reseed_counter > prng_reseed_limit) {
--
2.9.3