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


Groups > linux.kernel > #1477118 > unrolled thread

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

Started byColin King <colin.king@canonical.com>
First post2016-09-06 09:30 +0200
Last post2016-09-06 09:30 +0200
Articles 1 — 1 participant

Back to article view | Back to linux.kernel


Contents

  [PATCH][V2] s390/crypto: initialize ret to nbytes to avoid returning garbage value Colin King <colin.king@canonical.com> - 2016-09-06 09:30 +0200

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

FromColin King <colin.king@canonical.com>
Date2016-09-06 09:30 +0200
Subject[PATCH][V2] s390/crypto: initialize ret to nbytes to avoid returning garbage value
Message-ID<seiZr-7fd-15@gated-at.bofh.it>
From: Colin Ian King <colin.king@canonical.com>

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@canonical.com>
---
 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

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web