[PATCH] crypto: aspeed - Fix dma_unmap_sg() direction

Thomas Fourier posted 1 patch 5 months ago
There is a newer version of this series
drivers/crypto/aspeed/aspeed-hace-crypto.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] crypto: aspeed - Fix dma_unmap_sg() direction
Posted by Thomas Fourier 5 months ago
It seems like everywhere in this file, when the request is not
bidirectional, req->src is mapped with DMA_TO_DEVICE and req->src is
mapped with DMA_FROM_DEVICE.

Fixes: 62f58b1637b7 ("crypto: aspeed - add HACE crypto driver")
Cc: <stable@vger.kernel.org>
Signed-off-by: Thomas Fourier <fourier.thomas@gmail.com>
---
 drivers/crypto/aspeed/aspeed-hace-crypto.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/crypto/aspeed/aspeed-hace-crypto.c b/drivers/crypto/aspeed/aspeed-hace-crypto.c
index a72dfebc53ff..fa201dae1f81 100644
--- a/drivers/crypto/aspeed/aspeed-hace-crypto.c
+++ b/drivers/crypto/aspeed/aspeed-hace-crypto.c
@@ -346,7 +346,7 @@ static int aspeed_sk_start_sg(struct aspeed_hace_dev *hace_dev)
 
 	} else {
 		dma_unmap_sg(hace_dev->dev, req->dst, rctx->dst_nents,
-			     DMA_TO_DEVICE);
+			     DMA_FROM_DEVICE);
 		dma_unmap_sg(hace_dev->dev, req->src, rctx->src_nents,
 			     DMA_TO_DEVICE);
 	}
-- 
2.43.0
Re: [PATCH] crypto: aspeed - Fix dma_unmap_sg() direction
Posted by Andrew Jeffery 5 months ago
On Fri, 2025-09-05 at 13:51 +0200, Thomas Fourier wrote:
> It seems like everywhere in this file, when the request is not
> bidirectional, req->src is mapped with DMA_TO_DEVICE 
> 

Okay, however:

> and req->src is
> mapped with DMA_FROM_DEVICE.

By the patch itself, one should refer to req->dst?

Andrew

> 
> Fixes: 62f58b1637b7 ("crypto: aspeed - add HACE crypto driver")
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Thomas Fourier <fourier.thomas@gmail.com>
> ---
>  drivers/crypto/aspeed/aspeed-hace-crypto.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/crypto/aspeed/aspeed-hace-crypto.c b/drivers/crypto/aspeed/aspeed-hace-crypto.c
> index a72dfebc53ff..fa201dae1f81 100644
> --- a/drivers/crypto/aspeed/aspeed-hace-crypto.c
> +++ b/drivers/crypto/aspeed/aspeed-hace-crypto.c
> @@ -346,7 +346,7 @@ static int aspeed_sk_start_sg(struct aspeed_hace_dev *hace_dev)
>  
>         } else {
>                 dma_unmap_sg(hace_dev->dev, req->dst, rctx->dst_nents,
> -                            DMA_TO_DEVICE);
> +                            DMA_FROM_DEVICE);
>                 dma_unmap_sg(hace_dev->dev, req->src, rctx->src_nents,
>                              DMA_TO_DEVICE);
>         }