Re: [PATCH v2] crypto: atmel-tdes - use scatterlist length before DMA mapping

From: Herbert Xu

Date: Sun Jul 05 2026 - 04:29:22 EST


On Thu, Jun 11, 2026 at 12:36:35PM +0200, Thorsten Blum wrote:
> Using sg_dma_len() is only valid after mapping the scatterlist with
> dma_map_sg(). However, atmel_tdes_crypt_start() uses it before mapping
> to compare input/output lengths and to compute the transfer count.
>
> Use the original scatterlist lengths before DMA mapping to avoid reading
> stale or uninitialized DMA lengths when CONFIG_NEED_SG_DMA_LENGTH=y.
>
> Drop the output scatterlist length in the fast path since it is equal to
> ->in_sg->length and does not change the transfer count.
>
> Fixes: 13802005d8f2 ("crypto: atmel - add Atmel DES/TDES driver")
> Fixes: 1f858040c2f7 ("crypto: atmel-tdes - add support for latest release of the IP (0x700)")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Thorsten Blum <thorsten.blum@xxxxxxxxx>
> ---
> Changes in v2:
> - Drop ->out_sg->length in the fast path (Herbert)
> - v1: https://lore.kernel.org/lkml/20260531204115.689052-3-thorsten.blum@xxxxxxxxx/
> ---
> drivers/crypto/atmel-tdes.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)

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