linux-crypto.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Herbert Xu <herbert@gondor.apana.org.au>
To: Xiaoliang Pang <dawning.pang@gmail.com>
Cc: davem@davemloft.net, matthias.bgg@gmail.com, swboyd@chromium.org,
	yuehaibing@huawei.com, tianjia.zhang@linux.alibaba.com,
	ryder.lee@mediatek.com, linux-crypto@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org,
	dawning.pang@gmail.com
Subject: Re: [PATCH] cypto: mediatek - fix leaks in mtk_desc_ring_alloc
Date: Fri, 4 Sep 2020 17:21:54 +1000	[thread overview]
Message-ID: <20200904072154.GA24603@gondor.apana.org.au> (raw)
In-Reply-To: <20200903063800.27288-1-dawning.pang@gmail.com>

Xiaoliang Pang <dawning.pang@gmail.com> wrote:
> In the init loop, if an error occurs in function 'dma_alloc_coherent',
> then goto the err_cleanup section,
> in the cleanup loop, after run i--, 
> the struct mtk_ring rising[i] will not be released,
> causing a memory leak
> 
> Signed-off-by: Xiaoliang Pang <dawning.pang@gmail.com>
> ---
> drivers/crypto/mediatek/mtk-platform.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/crypto/mediatek/mtk-platform.c b/drivers/crypto/mediatek/mtk-platform.c
> index 7e3ad085b5bd..05d341e4a696 100644
> --- a/drivers/crypto/mediatek/mtk-platform.c
> +++ b/drivers/crypto/mediatek/mtk-platform.c
> @@ -469,7 +469,7 @@ static int mtk_desc_ring_alloc(struct mtk_cryp *cryp)
>        return 0;
> 
> err_cleanup:
> -       for (; i--; ) {
> +       for (; i >= 0; --i) {

How about a do while loop instead?

Thanks,
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

      reply	other threads:[~2020-09-04  7:22 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-03  6:38 [PATCH] cypto: mediatek - fix leaks in mtk_desc_ring_alloc Xiaoliang Pang
2020-09-04  7:21 ` Herbert Xu [this message]

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=20200904072154.GA24603@gondor.apana.org.au \
    --to=herbert@gondor.apana.org.au \
    --cc=davem@davemloft.net \
    --cc=dawning.pang@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=matthias.bgg@gmail.com \
    --cc=ryder.lee@mediatek.com \
    --cc=swboyd@chromium.org \
    --cc=tianjia.zhang@linux.alibaba.com \
    --cc=yuehaibing@huawei.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).