]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
udmabuf: use sgtable-based scatterlist wrappers
authorMarek Szyprowski <m.szyprowski@samsung.com>
Wed, 7 May 2025 16:09:12 +0000 (18:09 +0200)
committerChristian König <christian.koenig@amd.com>
Wed, 11 Jun 2025 11:18:07 +0000 (13:18 +0200)
Use common wrappers operating directly on the struct sg_table objects to
fix incorrect use of scatterlists sync calls. dma_sync_sg_for_*()
functions have to be called with the number of elements originally passed
to dma_map_sg_*() function, not the one returned in sgtable's nents.

Fixes: 1ffe09590121 ("udmabuf: fix dma-buf cpu access")
CC: stable@vger.kernel.org
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Acked-by: Vivek Kasireddy <vivek.kasireddy@intel.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Christian König <christian.koenig@amd.com>
Link: https://lore.kernel.org/r/20250507160913.2084079-3-m.szyprowski@samsung.com
drivers/dma-buf/udmabuf.c

index 7eee3eb47a8ee8270231bc2d7fb1701df191a5d9..c9d0c68d2fcb0fb58e2f4c5f174a9125ab53c97c 100644 (file)
@@ -264,8 +264,7 @@ static int begin_cpu_udmabuf(struct dma_buf *buf,
                        ubuf->sg = NULL;
                }
        } else {
-               dma_sync_sg_for_cpu(dev, ubuf->sg->sgl, ubuf->sg->nents,
-                                   direction);
+               dma_sync_sgtable_for_cpu(dev, ubuf->sg, direction);
        }
 
        return ret;
@@ -280,7 +279,7 @@ static int end_cpu_udmabuf(struct dma_buf *buf,
        if (!ubuf->sg)
                return -EINVAL;
 
-       dma_sync_sg_for_device(dev, ubuf->sg->sgl, ubuf->sg->nents, direction);
+       dma_sync_sgtable_for_device(dev, ubuf->sg, direction);
        return 0;
 }