Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

udmabuf: use sgtable-based scatterlist wrappers

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

authored by

Marek Szyprowski and committed by
Christian König
afe38284 aa3f93cd

+2 -3
+2 -3
drivers/dma-buf/udmabuf.c
··· 264 264 ubuf->sg = NULL; 265 265 } 266 266 } else { 267 - dma_sync_sg_for_cpu(dev, ubuf->sg->sgl, ubuf->sg->nents, 268 - direction); 267 + dma_sync_sgtable_for_cpu(dev, ubuf->sg, direction); 269 268 } 270 269 271 270 return ret; ··· 279 280 if (!ubuf->sg) 280 281 return -EINVAL; 281 282 282 - dma_sync_sg_for_device(dev, ubuf->sg->sgl, ubuf->sg->nents, direction); 283 + dma_sync_sgtable_for_device(dev, ubuf->sg, direction); 283 284 return 0; 284 285 } 285 286