From patchwork Wed Feb 14 21:40:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SF Markus Elfring X-Patchwork-Id: 10219999 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 841B1601C2 for ; Wed, 14 Feb 2018 21:40:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6325E290E4 for ; Wed, 14 Feb 2018 21:40:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 61A8F29144; Wed, 14 Feb 2018 21:40: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 6FA502918C for ; Wed, 14 Feb 2018 21:40:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1031473AbeBNVkf (ORCPT ); Wed, 14 Feb 2018 16:40:35 -0500 Received: from mout.web.de ([212.227.15.4]:40361 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1031455AbeBNVke (ORCPT ); Wed, 14 Feb 2018 16:40:34 -0500 Received: from [192.168.1.2] ([78.48.82.239]) by smtp.web.de (mrweb004 [213.165.67.108]) with ESMTPSA (Nemesis) id 0MRA59-1fEQLc0NP5-00UXl9; Wed, 14 Feb 2018 22:40:27 +0100 Subject: [PATCH 2/2] crypto: bcm: One function call less in do_shash() after error detection From: SF Markus Elfring To: linux-crypto@vger.kernel.org, Arvind Yadav , Colin Ian King , "David S. Miller" , Herbert Xu , Rob Rice , Steve Lin Cc: LKML , kernel-janitors@vger.kernel.org References: <68946b12-83d6-ab74-fd54-71b23cf9b7ef@users.sourceforge.net> Message-ID: <55bdcf76-f1c9-180d-6798-959e617b10ac@users.sourceforge.net> Date: Wed, 14 Feb 2018 22:40:26 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <68946b12-83d6-ab74-fd54-71b23cf9b7ef@users.sourceforge.net> Content-Language: en-US X-Provags-ID: V03:K0:cvcOAkDMzLmPq1i0KvCjqGrMttGJPNENznKZFsQRYfulFQQqWch 4GoDOZunAH2PDjm4fJrAzYXbnCp+LSw14uo7AaY3b+x+u/CTD5aDQUYgvYPZyz2NQztllgS Ice/6NXv5J9oAThLEXTrngqgYt+6mCp8KRxEwZDrVIh4d2MKqC1tUjVbfmmT4+KyTizkwsJ xr5I0uk9jGz6u0+uOOJxw== X-UI-Out-Filterresults: notjunk:1; V01:K0:oxT/3ob+ulE=:5jfHN9RSqSIliB4alksj+L TVJyRCqBIsweYyQklXUY81YFB5ZGYroNngvUt+M2LzwKhj3Q67v/V5cEyKPCoD7h9531qIi8K JKb15rwjtKvUH52iQ8GV1kz/8qrrIe5sgE1ehQOwDeFhmfkCobwm6CgtVgt4tpAaMTYFVu9Ng JHjUbgRwoJyJK9bZ3L7SbHJEcUY3F20a9wZMrvEXvBMAs6U4Jrq47SjrbzEluNL+1E+2xUbVa Ks9zKTrmULcoUzI6yAv1Uj+4fBMgMtaoesWNveIuFcXVrIWWG5Bzper5fxhmFFn6+GtibsgRy cnS0DuM+2P4zgf4xR15gp8oxMsVswP2zLaGQ5eJBAbDQQyceTkOfYqA3E8bZo6I/329WY+c7x 4LdVAB4rNM6DZftrTd0BdzT+X5xg/9B+QMWAqduzdaOccsWAdveVgtnpDJYtum2G4bCOlfMiH yzi6acqJLhD6Q8+fzrx4ljkM4jkOpK3VmWyAQq4hC5H1TSXQOVzIPavnJQrtUvTYXWHP3BGtg BuE26I0EYWQSafVxPpWEC5AwhtPKQNt7Abs5LMuui9ORwiFUlvSq+Yv8xE/hl0ssYUgTMbSQ5 DZeTjjxuN1ullilQ38DAFpDCDeD+TS1rT+obAuXu6R32QTydG1+pXnILo8K0JOap72+rGK/XT KTEbkav8N9Ak7ixpWpWVp0Dey+ecjDAyj1LFNIW8eWE9K821c3Q52Ajb99AuWOdqGPIjsm88I k6jmFt+POLiEHlfExZKDDiOKWkynYDOePoX9YqSwY455TJuVrovJ27aEw35vtFTxn5gV9l9Dk hOlVWrLoMS+jUdBBZm/HgbL6ksJEugmBFH5ac4YIkeT2T3c1pE= 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: Wed, 14 Feb 2018 22:22:20 +0100 The kfree() function was called in one case by the do_shash() function during error handling even if the passed variable contained a null pointer. * Reorder two function calls at the end. * Add a jump target. Signed-off-by: Markus Elfring --- drivers/crypto/bcm/util.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/crypto/bcm/util.c b/drivers/crypto/bcm/util.c index a912c6ad3e85..c141a0242223 100644 --- a/drivers/crypto/bcm/util.c +++ b/drivers/crypto/bcm/util.c @@ -279,7 +279,7 @@ int do_shash(unsigned char *name, unsigned char *result, sdesc = kmalloc(size, GFP_KERNEL); if (!sdesc) { rc = -ENOMEM; - goto do_shash_err; + goto free_shash; } sdesc->shash.tfm = hash; sdesc->shash.flags = 0x0; @@ -314,9 +314,9 @@ int do_shash(unsigned char *name, unsigned char *result, pr_err("%s: Could not generate %s hash\n", __func__, name); do_shash_err: - crypto_free_shash(hash); kfree(sdesc); - +free_shash: + crypto_free_shash(hash); return rc; }