From: SF Markus Elfring <elfring@users.sourceforge.net>
To: linux-crypto@vger.kernel.org,
Arvind Yadav <arvind.yadav.cs@gmail.com>,
Colin Ian King <colin.king@canonical.com>,
"David S. Miller" <davem@davemloft.net>,
Herbert Xu <herbert@gondor.apana.org.au>,
Rob Rice <rob.rice@broadcom.com>,
Steve Lin <steven.lin1@broadcom.com>
Cc: LKML <linux-kernel@vger.kernel.org>, kernel-janitors@vger.kernel.org
Subject: [PATCH 2/2] crypto: bcm: One function call less in do_shash() after error detection
Date: Wed, 14 Feb 2018 22:40:26 +0100 [thread overview]
Message-ID: <55bdcf76-f1c9-180d-6798-959e617b10ac@users.sourceforge.net> (raw)
In-Reply-To: <68946b12-83d6-ab74-fd54-71b23cf9b7ef@users.sourceforge.net>
From: Markus Elfring <elfring@users.sourceforge.net>
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 <elfring@users.sourceforge.net>
---
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;
}
--
2.16.1
next prev parent reply other threads:[~2018-02-14 21:40 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-14 21:38 [PATCH 0/2] crypto/bcm: Adjustments for do_shash() SF Markus Elfring
2018-02-14 21:39 ` [PATCH 1/2] crypto: bcm: Delete an error message for a failed memory allocation in do_shash() SF Markus Elfring
2018-02-22 15:13 ` Herbert Xu
2018-02-14 21:40 ` SF Markus Elfring [this message]
2018-02-22 13:42 ` [PATCH 2/2] crypto: bcm: One function call less in do_shash() after error detection Herbert Xu
2018-02-23 8:23 ` [2/2] " SF Markus Elfring
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=55bdcf76-f1c9-180d-6798-959e617b10ac@users.sourceforge.net \
--to=elfring@users.sourceforge.net \
--cc=arvind.yadav.cs@gmail.com \
--cc=colin.king@canonical.com \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rob.rice@broadcom.com \
--cc=steven.lin1@broadcom.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®