Skip to contentSkip to conversation

dma-debug: fix physical address retrieval in debug_dma_sync_sg_for_device

PATCH In review lirongqing 2 participants 2 messages Jun 3 DMA mapping helpers

lore
Share & tools
lore

lirongqing

author
#0 lore raw

PATCH 1/1 dma-debug: fix physical address retrieval in debug_dma_sync_sg_for_device

From: Li RongQing <[email protected]>

In debug_dma_sync_sg_for_device(), when iterating over a scatterlist, the debug entry population mistakenly uses the head of the scatterlist 'sg' to fetch the physical address via sg_phys(), instead of using the current iterator variable 's'.

This causes dma-debug to track the physical address of the very first scatterlist entry for all subsequent entries in the list.

Fix this by passing the correct loop iterator 's' to sg_phys()

Fixes 9d4f645a1fd49ee ("dma-debug: store a phys_addr_t in struct dma_debug_entry")
---
 kernel/dma/debug.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/dma/debug.c +1 -1
index 3248f8b..2c0e2cd 100644
@@ -1556,7 +1556,7 @@ void debug_dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg,
 		struct dma_debug_entry ref = {
 			.type           = dma_debug_sg,
 			.dev            = dev,
-			.paddr		= sg_phys(sg),
+			.paddr		= sg_phys(s),
 			.dev_addr       = sg_dma_address(s),
 			.size           = sg_dma_len(s),
 			.direction      = direction,
Signature · 1 line
2.9.4
maintainer
#1 lore raw
Quoted 7 lines · lirongqing

From: Li RongQing <[email protected]>

In debug_dma_sync_sg_for_device(), when iterating over a scatterlist, the debug entry population mistakenly uses the head of the scatterlist 'sg' to fetch the physical address via sg_phys(), instead of using the current iterator variable 's'.

Quoted 7 lines

This causes dma-debug to track the physical address of the very first scatterlist entry for all subsequent entries in the list.

Fix this by passing the correct loop iterator 's' to sg_phys()

Fixes 9d4f645a1fd49ee ("dma-debug: store a phys_addr_t in struct dma_debug_entry")

Nice catch! Applied to dma-mapping-fixes, thanks!

Quoted 9 lines
---
 kernel/dma/debug.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/dma/debug.c +0 -0
index 3248f8b..2c0e2cd 100644

kernel/dma/debug.c void debug_dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg, · line 1562

Quoted 8 lines
kernel/dma/debug.c +1 -1
@@ -1556,7 +1556,7 @@ void debug_dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg,
 		struct dma_debug_entry ref = {
 			.type           = dma_debug_sg,
 			.dev            = dev,
-			.paddr		= sg_phys(sg),
+			.paddr		= sg_phys(s),
 			.dev_addr       = sg_dma_address(s),
 			.size           = sg_dma_len(s),
 			.direction      = direction,

Best regards

Signature · 2 lines
Marek Szyprowski, PhD
Samsung R&D Institute Poland