Re: [PATCH 08/10] crypto: qce - Pass mapped scatterlist count to qce_dma_prep_sgs()

From: Bartosz Golaszewski

Date: Tue Nov 24 2026 - 07:49:15 EST


On Mon, Nov 23, 2026 at 03:09:59PM +0000, Lee Jones wrote:
> In qce_ahash_async_req_handle(), dma_map_sg() maps req->src and returns
> the number of coalesced DMA segments in ret, which is immediately
> overwritten when mapping rctx->result_sg. The function then passes the
> unmapped segment count rctx->src_nents to qce_dma_prep_sgs().
>
> When an IOMMU coalesces scatterlist entries so the mapped count is
> smaller than rctx->src_nents, dmaengine_prep_slave_sg() walks past the
> mapped entries and reads uninitialised DMA addresses and lengths from
> the tail of req->src, while dma_unmap_sg() still requires the original
> rctx->src_nents count.
>
> Save the mapped segment count from dma_map_sg() in a dedicated
> src_nents variable and pass it to qce_dma_prep_sgs(), matching the
> skcipher path.
>
> Fixes: ec8f5d8f6f76 ("crypto: qce - Qualcomm crypto engine driver")
> Closes: https://sashiko.dev/#/bug/linux-24490c31-257a-4148-a816-0aaf416f64a1
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Lee Jones <lee@xxxxxxxxxx>
> ---

Acked-by: Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxxxxxxxx>