From: Herbert Xu <herbert@gondor.apana.org.au>
To: Mohamad Raizudeen <raizudeen.kerneldev@gmail.com>
Cc: clabbe@baylibre.com, davem@davemloft.net,
skhan@linuxfoundation.org, me@brighamcampbell.com,
jkoolstra@xs4all.nl, linux-crypto@vger.kernel.org,
linux-amlogic@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] crypto: amlogic: Fix DMA memory leak in cipher error path
Date: Fri, 11 Sep 2026 15:14:14 +1000 [thread overview]
Message-ID: <aqOOJoA2mVT9270l@gondor.apana.org.au> (raw)
In-Reply-To: <20260822084509.26385-1-raizudeen.kerneldev@gmail.com>
On Sat, Aug 22, 2026 at 02:15:08PM +0530, Mohamad Raizudeen wrote:
> A DMA memory leak occurs in meson_cipher() on the mapping error paths.
> The driver jumps to the end of the function without unmapping the
> previously mapped source scatterlist and key/IV buffer when the
> destination apping fails.
>
> Additionally, a memory leak occurs when a scatterlist mapping succeeds
> but the returned count exceeds the driver's MAXDESC limit. In this case,
> the driver rejects the mapping without unmapping it. The BIDIRECTIONAL
> mapping branch also lacks the required 'MAXDESC -3' upper bound check.
>
> Fix this by introducing proper error labels, error_src and error_keyiv
> and unmap resources immediately inside the calidation checks to ensure
> all successfully mapped resources are cleaned up before returning the
> error.
>
> Fixes: 48fe583fe541 ("crypto: amlogic - Add crypto accelerator for amlogic GXL")
> Signed-off-by: Mohamad Raizudeen <raizudeen.kerneldev@gmail.com>
> ---
> Changes in v2:
> - Add missing '> MAXDESC - 3' upper bound check for the BIDIRECTIONAL
> scatterlist mapping branch.
> - Unmap scatterlists immediately inside the 'if' block when the count
> exceeds MAXDESC - 3, because dma_map_sg() actually succeeds in this
> case and the mapping must be undone.
>
> drivers/crypto/amlogic/amlogic-gxl-cipher.c | 25 ++++++++++++++++-----
> 1 file changed, 20 insertions(+), 5 deletions(-)
Patch applied. 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
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
prev parent reply other threads:[~2026-09-11 5:14 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-22 8:45 Mohamad Raizudeen
2026-08-22 8:57 ` sashiko-bot
2026-09-11 5:14 ` 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=aqOOJoA2mVT9270l@gondor.apana.org.au \
--to=herbert@gondor.apana.org.au \
--cc=clabbe@baylibre.com \
--cc=davem@davemloft.net \
--cc=jkoolstra@xs4all.nl \
--cc=linux-amlogic@lists.infradead.org \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=me@brighamcampbell.com \
--cc=raizudeen.kerneldev@gmail.com \
--cc=skhan@linuxfoundation.org \
/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®