From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754992AbcIFHKk (ORCPT ); Tue, 6 Sep 2016 03:10:40 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:54046 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754722AbcIFHKh (ORCPT ); Tue, 6 Sep 2016 03:10:37 -0400 X-IBM-Helo: d06dlp03.portsmouth.uk.ibm.com X-IBM-MailFrom: schwidefsky@de.ibm.com X-IBM-RcptTo: linux-crypto@vger.kernel.org;linux-kernel@vger.kernel.org;linux-s390@vger.kernel.org Date: Tue, 6 Sep 2016 09:10:25 +0200 From: Martin Schwidefsky To: Colin King Cc: Herbert Xu , "David S . Miller" , Heiko Carstens , linux-crypto@vger.kernel.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] s390/crypto: initialize ret to zero to avoid returning garbage value In-Reply-To: <20160905162118.16510-1-colin.king@canonical.com> References: <20160905162118.16510-1-colin.king@canonical.com> X-Mailer: Claws Mail 3.9.3 (GTK+ 2.24.23; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16090607-0016-0000-0000-0000022C7012 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16090607-0017-0000-0000-000022E0BB5E Message-Id: <20160906091025.20726b83@mschwide> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2016-09-06_02:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1604210000 definitions=main-1609060110 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 5 Sep 2016 17:21:18 +0100 Colin King wrote: > From: Colin Ian King > > 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. > > Signed-off-by: Colin Ian King > --- > 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..a21fdf4 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 = 0; > > /* reseed needed ? */ > if (prng_data->ppnows.reseed_counter > prng_reseed_limit) { This issue has been introduced by git commit 0177db01adf26cf9 "s390/crypto: simplify return code handling" which is only on the features branch right now. And to set ret=0 does not fix the problem. The correct fix is to return nbytes. Still a good catch though. -- blue skies, Martin. "Reality continues to ruin my life." - Calvin.