From patchwork Tue Sep 6 07:25:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin King X-Patchwork-Id: 9315823 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7E6BC60752 for ; Tue, 6 Sep 2016 07:26:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 982EA286F3 for ; Tue, 6 Sep 2016 07:26:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8CDF428BA1; Tue, 6 Sep 2016 07:26:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5998E286F3 for ; Tue, 6 Sep 2016 07:26:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932486AbcIFH0n (ORCPT ); Tue, 6 Sep 2016 03:26:43 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:43728 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932140AbcIFH0n (ORCPT ); Tue, 6 Sep 2016 03:26:43 -0400 Received: from 1.general.cking.uk.vpn ([10.172.193.212] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1bhAmC-0003ef-Ur; Tue, 06 Sep 2016 07:26:37 +0000 From: Colin King To: Herbert Xu , "David S . Miller" , Martin Schwidefsky , Heiko Carstens , linux-crypto@vger.kernel.org, linux-s390@vger.kernel.org Cc: linux-kernel@vger.kernel.org Subject: [PATCH][V2] s390/crypto: initialize ret to nbytes to avoid returning garbage value Date: Tue, 6 Sep 2016 08:25:13 +0100 Message-Id: <20160906072513.7210-1-colin.king@canonical.com> X-Mailer: git-send-email 2.9.3 MIME-Version: 1.0 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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. 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 --- 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) {