]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
crypto: cavium/cpt - fix DMA cleanup using wrong loop index
authorFelix Gu <ustc.gu@gmail.com>
Tue, 2 Jun 2026 14:55:35 +0000 (22:55 +0800)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 12 Jun 2026 01:56:45 +0000 (09:56 +0800)
The sg_cleanup error path used list[i] instead of list[j] when unmapping
DMA buffers, leaking successfully mapped entries and repeatedly unmapping
the failed one.

Fixes: c694b233295b ("crypto: cavium - Add the Virtual Function driver for CPT")
Signed-off-by: Felix Gu <ustc.gu@gmail.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/cavium/cpt/cptvf_reqmanager.c

index e183b60277ff1e046fdcfc75bc9ec34575d8a0e3..de305cbeccbe0e882db905ad07b8a780fe41b1ca 100644 (file)
@@ -108,8 +108,8 @@ static int setup_sgio_components(struct cpt_vf *cptvf, struct buf_ptr *list,
 sg_cleanup:
        for (j = 0; j < i; j++) {
                if (list[j].dma_addr) {
-                       dma_unmap_single(&pdev->dev, list[i].dma_addr,
-                                        list[i].size, DMA_BIDIRECTIONAL);
+                       dma_unmap_single(&pdev->dev, list[j].dma_addr,
+                                        list[j].size, DMA_BIDIRECTIONAL);
                }
 
                list[j].dma_addr = 0;