From: Kees Cook <keescook@chromium.org>
To: Corentin Labbe <clabbe@baylibre.com>
Cc: davem@davemloft.net, herbert@gondor.apana.org.au,
keescook+coverity-bot@chromium.org, narmstrong@baylibre.com,
linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] crypto: amlogic - fix two resources leak
Date: Fri, 8 Nov 2019 13:00:36 -0800 [thread overview]
Message-ID: <201911081300.B869D22BB@keescook> (raw)
In-Reply-To: <1573206317-9926-1-git-send-email-clabbe@baylibre.com>
On Fri, Nov 08, 2019 at 09:45:17AM +0000, Corentin Labbe wrote:
> 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>
Thanks!
Reviewed-by: Kees Cook <keescook@chromium.org>
-Kees
> ---
> 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
>
--
Kees Cook
next prev parent reply other threads:[~2019-11-08 21:00 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-08 9:45 [PATCH] crypto: amlogic - fix two resources leak Corentin Labbe
2019-11-08 21:00 ` Kees Cook [this message]
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=201911081300.B869D22BB@keescook \
--to=keescook@chromium.org \
--cc=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).