From: Corentin Labbe <clabbe@baylibre.com>
To: davem@davemloft.net, herbert@gondor.apana.org.au,
keescook+coverity-bot@chromium.org, narmstrong@baylibre.com
Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org,
Corentin Labbe <clabbe@baylibre.com>
Subject: [PATCH] crypto: amlogic - fix two resources leak
Date: Fri, 8 Nov 2019 09:45:17 +0000 [thread overview]
Message-ID: <1573206317-9926-1-git-send-email-clabbe@baylibre.com> (raw)
This patch fixes two resources leak that occur on error path.
Reported-by: coverity-bot <keescook+coverity-bot@chromium.org>
Addresses-Coverity-ID: 1487403 ("RESOURCE_LEAK")
Addresses-Coverity-ID: 1487401 ("Resource leaks")
Fixes: 48fe583fe541 ("crypto: amlogic - Add crypto accelerator for amlogic GXL")
Signed-off-by: Corentin Labbe <clabbe@baylibre.com>
---
drivers/crypto/amlogic/amlogic-gxl-cipher.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/drivers/crypto/amlogic/amlogic-gxl-cipher.c b/drivers/crypto/amlogic/amlogic-gxl-cipher.c
index e9283ffdbd23..58b717aab6e8 100644
--- a/drivers/crypto/amlogic/amlogic-gxl-cipher.c
+++ b/drivers/crypto/amlogic/amlogic-gxl-cipher.c
@@ -131,7 +131,8 @@ static int meson_cipher(struct skcipher_request *areq)
if (areq->iv && ivsize > 0) {
if (ivsize > areq->cryptlen) {
dev_err(mc->dev, "invalid ivsize=%d vs len=%d\n", ivsize, areq->cryptlen);
- return -EINVAL;
+ err = -EINVAL;
+ goto theend;
}
memcpy(bkeyiv + 32, areq->iv, ivsize);
keyivlen = 48;
@@ -151,9 +152,10 @@ static int meson_cipher(struct skcipher_request *areq)
phykeyiv = dma_map_single(mc->dev, bkeyiv, keyivlen,
DMA_TO_DEVICE);
- if (dma_mapping_error(mc->dev, phykeyiv)) {
+ err = dma_mapping_error(mc->dev, phykeyiv);
+ if (err) {
dev_err(mc->dev, "Cannot DMA MAP KEY IV\n");
- return -EFAULT;
+ goto theend;
}
tloffset = 0;
@@ -245,7 +247,6 @@ static int meson_cipher(struct skcipher_request *areq)
if (areq->iv && ivsize > 0) {
if (rctx->op_dir == MESON_DECRYPT) {
memcpy(areq->iv, backup_iv, ivsize);
- kzfree(backup_iv);
} else {
scatterwalk_map_and_copy(areq->iv, areq->dst,
areq->cryptlen - ivsize,
@@ -254,6 +255,7 @@ static int meson_cipher(struct skcipher_request *areq)
}
theend:
kzfree(bkeyiv);
+ kzfree(backup_iv);
return err;
}
--
2.23.0
next reply other threads:[~2019-11-08 9:45 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-08 9:45 Corentin Labbe [this message]
2019-11-08 21:00 ` [PATCH] crypto: amlogic - fix two resources leak Kees Cook
2019-11-15 6:07 ` Herbert Xu
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=1573206317-9926-1-git-send-email-clabbe@baylibre.com \
--to=clabbe@baylibre.com \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=keescook+coverity-bot@chromium.org \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=narmstrong@baylibre.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;
as well as URLs for NNTP newsgroup(s).