]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
crypto: starfive - use scatterlist length before DMA mapping
authorThorsten Blum <thorsten.blum@linux.dev>
Sat, 25 Jul 2026 09:06:10 +0000 (11:06 +0200)
committerHerbert Xu <herbert@gondor.apana.org.au>
Thu, 30 Jul 2026 07:30:50 +0000 (17:30 +1000)
Using sg_dma_len() is only valid after mapping a scatterlist with
dma_map_sg(). However, starfive_aes_aead_do_one_req() uses it before
mapping the scatterlist.

Use the original scatterlist length because the DMA length has not been
populated yet when CONFIG_NEED_SG_DMA_LENGTH=y.

Fixes: 7467147ef9bf ("crypto: starfive - Use dma for aes requests")
Cc: stable@vger.kernel.org
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/starfive/jh7110-aes.c

index a0713aa21250adf92f3cb76bc355d39505e713d8..f59adb2a56510ae55b6bb5497fa8690e4a2b596f 100644 (file)
@@ -677,7 +677,7 @@ static int starfive_aes_aead_do_one_req(struct crypto_engine *engine, void *areq
 
        if (cryp->total_in)
                sg_zero_buffer(rctx->in_sg, sg_nents(rctx->in_sg),
-                              sg_dma_len(rctx->in_sg) - cryp->total_in,
+                              rctx->in_sg->length - cryp->total_in,
                               cryp->total_in);
 
        ctx->rctx = rctx;