Skip to contentSkip to conversation

blk-mq-dma: always initialize dma state

PATCH Applied Keith Busch 3 participants 3 messages Dec 10, 2025 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 blk-mq-dma: always initialize dma state

From: Keith Busch <[email protected]>

Ensure the dma state is initialized when we're not using the contiguous iova, otherwise the caller may be using a stale state from a previous request that could use the coalesed iova allocation.

Fixes 2f6b2565d43cdb5 ("block: accumulate memory segment gaps per bio")

---
v1->v2:

Simpler logic to always do the state initialization

 block/blk-mq-dma.c | 1 +
 1 file changed, 1 insertion(+)
block/blk-mq-dma.c +1 -0
index e9108ccaf4b06..6dc7a3c23ac8d 100644
@@ -199,6 +199,7 @@ static bool blk_dma_map_iter_start(struct request *req, struct device *dma_dev,
 	if (blk_can_dma_map_iova(req, dma_dev) &&
 	    dma_iova_try_alloc(dma_dev, state, vec.paddr, total_len))
 		return blk_rq_dma_map_iova(req, dma_dev, state, iter, &vec);
+	memset(state, 0, sizeof(*state));
 	return blk_dma_map_direct(req, dma_dev, iter, &vec);
 }
 
Signature · 1 line
2.47.3
maintainer Applied
#2 lore raw
In reply to Keith Busch
Quoted 5 lines · Keith Busch

Ensure the dma state is initialized when we're not using the contiguous iova, otherwise the caller may be using a stale state from a previous request that could use the coalesed iova allocation.

Applied, thanks!

[1/1] blk-mq-dma: always initialize dma state

      commit: a0750fae73c55112ea11a4867bee40f11e679405

Best regards,

Signature · 1 line
Jens Axboe