public inbox for linux-block@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] blk-mq-dma: always initialize dma state
@ 2025-12-10  6:49 Keith Busch
  2025-12-10  6:54 ` Christoph Hellwig
  2025-12-10 10:38 ` Sebastian Ott
  0 siblings, 2 replies; 5+ messages in thread
From: Keith Busch @ 2025-12-10  6:49 UTC (permalink / raw)
  To: linux-block, axboe, hch; +Cc: Keith Busch, Sebastian Ott

From: Keith Busch <kbusch@kernel.org>

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")
Reported-by: Sebastian Ott <sebott@redhat.com>
Signed-off-by: Keith Busch <kbusch@kernel.org>
---
 block/blk-mq-dma.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/block/blk-mq-dma.c b/block/blk-mq-dma.c
index e9108ccaf4b06..4ca768e0cc7eb 100644
--- a/block/blk-mq-dma.c
+++ b/block/blk-mq-dma.c
@@ -196,8 +196,9 @@ static bool blk_dma_map_iter_start(struct request *req, struct device *dma_dev,
 		return false;
 	}
 
-	if (blk_can_dma_map_iova(req, dma_dev) &&
-	    dma_iova_try_alloc(dma_dev, state, vec.paddr, total_len))
+	if (!blk_can_dma_map_iova(req, dma_dev))
+		memset(state, 0, sizeof(*state));
+	else if (dma_iova_try_alloc(dma_dev, state, vec.paddr, total_len))
 		return blk_rq_dma_map_iova(req, dma_dev, state, iter, &vec);
 	return blk_dma_map_direct(req, dma_dev, iter, &vec);
 }
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-12-10 10:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-10  6:49 [PATCH] blk-mq-dma: always initialize dma state Keith Busch
2025-12-10  6:54 ` Christoph Hellwig
2025-12-10  7:06   ` Keith Busch
2025-12-10  8:25     ` Christoph Hellwig
2025-12-10 10:38 ` Sebastian Ott

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox