From patchwork Thu May 11 15:12:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SF Markus Elfring X-Patchwork-Id: 9722047 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 894CF60236 for ; Thu, 11 May 2017 15:12:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7D7C526224 for ; Thu, 11 May 2017 15:12:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7201926BE9; Thu, 11 May 2017 15:12:56 +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=unavailable 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 07BA926224 for ; Thu, 11 May 2017 15:12:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756360AbdEKPMk (ORCPT ); Thu, 11 May 2017 11:12:40 -0400 Received: from mout.web.de ([212.227.15.4]:63035 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756462AbdEKPMi (ORCPT ); Thu, 11 May 2017 11:12:38 -0400 Received: from [192.168.1.3] ([77.182.250.240]) by smtp.web.de (mrweb003 [213.165.67.108]) with ESMTPSA (Nemesis) id 0MWBA1-1dXB2v26tV-00XKUq; Thu, 11 May 2017 17:12:16 +0200 To: linux-crypto@vger.kernel.org, "David S. Miller" , Herbert Xu Cc: LKML , kernel-janitors@vger.kernel.org, Wolfram Sang From: SF Markus Elfring Subject: [PATCH] crypto-testmgr: Delete an error message for a failed memory allocation in two functions Message-ID: <0168ce01-446b-a1f0-8a3f-55da49bdbd86@users.sourceforge.net> Date: Thu, 11 May 2017 17:12:11 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.0 MIME-Version: 1.0 Content-Language: en-US X-Provags-ID: V03:K0:RlwayE/XGhp8cs2OaoiVfuxqArSTdoUY04Y3WUVzJp9gAX6iSkl s3Wz4H6Nki32MGol5wcOKOWql6+K4T/sPVYx3Htr3j5tHb08rbfSuEMXDbgeSVPw7SuZBf+ RP2SEiU4YHE8R2AxJfEexKlP29oPXhc5UWFlx6KiyxDJ5so0T8VkEnNJxaT/h/zWyML7f/o +gpks+tXXto1ok3IBXsxA== X-UI-Out-Filterresults: notjunk:1; V01:K0:bQO6cQKU2sA=:QrysXKf6I1oErSmts+nhoB rGRYG7XCVcarwztRFQcckETcfGfkdVooTZET8lNioNUzKJiZJu/UHVzYFd2brJCSDqT0Qe02E 6sF52xQy3nTuTqC4L0TMbPoY/zWUCkksnQSPrGaptara/mrA6vLtOTSGtVXlznQr1siMImRCd z6vEn9go3FtShnqcUqJoNdkIXmStz9uyCfk/2INo3rW4Yn8nn19PFQb7wanDf/ayxTQib966g UXJmhSC1RwdgMaj7BgzdfepbfI19z52e77KUUiZm4bKYRfA8y2campKDKaxS1IxTV9blpe8IO J18IvmC7H9Zb5pd/ogdkL9FzF1LvLT2AMC+G+U4y030XSgAZmpe7+//TRdn/5LwStDTahi+wE JpZwUq8+HPo6Q3asHLXCkxMGW0n7PMEemethClumE7yQAiYRs9lXpbbCxwh8DSb3CO/M7ujaW 1Hj9R6qmVfL8sVQGPk3LeYR0Jfk62FVmLDkJ+jCmBw6e5G0xBeoqf4ZK/vzGcOlGEwJGlbxU7 3h4gCd4TP9kehGOa3oGn3eJDi4zV8S9sCsag0FKTuo6wWNPKRMZU9EFsbZXhyrx4YMtL52q9c UBTm36OVNts/iU6BSBc/UrYSR/gX386BZI9GgTyWoRDf3tmZgyO5syXFGy1jK46spGF+Ca6aw +TxEdcuuXHUx/+TqB0u4Kp0MmQGUmBaM1I6s+9YtycN25Xd4ykGYuPWaxkjJ7AQ36sG6aoDD4 LIpi7RvtDmWiP+rkS4SsLGPYpn+ab+OeeUGsYVARJpWM6OR5NGbYAMwUiCr3kH5uG4k7YPxgC zOzPo/Y 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: Markus Elfring Date: Thu, 11 May 2017 17:05:17 +0200 Omit an extra message for a memory allocation failure in these functions. This issue was detected by using the Coccinelle software. Link: http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refactor_Strings-WSang_0.pdf Signed-off-by: Markus Elfring --- crypto/testmgr.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/crypto/testmgr.c b/crypto/testmgr.c index 6f5f3ed8376c..392bb4f95024 100644 --- a/crypto/testmgr.c +++ b/crypto/testmgr.c @@ -217,10 +217,9 @@ static int ahash_partial_update(struct ahash_request **preq, statesize = crypto_ahash_statesize( crypto_ahash_reqtfm(req)); state = kmalloc(statesize + sizeof(guard), GFP_KERNEL); - if (!state) { - pr_err("alt: hash: Failed to alloc state for %s\n", algo); + if (!state) goto out_nostate; - } + memcpy(state + statesize, guard, sizeof(guard)); ret = crypto_ahash_export(req, state); WARN_ON(memcmp(state + statesize, guard, sizeof(guard))); @@ -1632,11 +1631,8 @@ static int test_cprng(struct crypto_rng *tfm, seedsize = crypto_rng_seedsize(tfm); seed = kmalloc(seedsize, GFP_KERNEL); - if (!seed) { - printk(KERN_ERR "alg: cprng: Failed to allocate seed space " - "for %s\n", algo); + if (!seed) return -ENOMEM; - } for (i = 0; i < tcount; i++) { memset(result, 0, 32);