All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drivers/dma: replace dma_free_coherent with dma_free_wc
@ 2025-09-12 15:01 Zilin Guan
  2025-09-12 17:06 ` Markus Elfring
  0 siblings, 1 reply; 2+ messages in thread
From: Zilin Guan @ 2025-09-12 15:01 UTC (permalink / raw)
  To: vkoul; +Cc: dmaengine, linux-kernel, jianhao.xu, Zilin Guan

The memory for the DMA descriptor pool (dma_desc_pool_virt) is allocated
by dma_alloc_wc, but it is freed by dma_free_coherent in the error
handling path. This is incorrect as DMA allocation and free functions
should be paired.

Using mismatched functions may lead to undefined behavior, memory leaks,
or system instability.

The fix is to use dma_free_wc to match the allocation function.

Signed-off-by: Zilin Guan <zilin@seu.edu.cn>
---
 drivers/dma/mv_xor.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/dma/mv_xor.c b/drivers/dma/mv_xor.c
index 1fdcb0f5c9e7..58de208fc50d 100644
--- a/drivers/dma/mv_xor.c
+++ b/drivers/dma/mv_xor.c
@@ -1163,7 +1163,7 @@ mv_xor_channel_add(struct mv_xor_device *xordev,
 err_free_irq:
 	free_irq(mv_chan->irq, mv_chan);
 err_free_dma:
-	dma_free_coherent(&pdev->dev, MV_XOR_POOL_SIZE,
+	dma_free_wc(&pdev->dev, MV_XOR_POOL_SIZE,
 			  mv_chan->dma_desc_pool_virt, mv_chan->dma_desc_pool);
 err_unmap_dst:
 	dma_unmap_single(dma_dev->dev, mv_chan->dummy_dst_addr,
-- 
2.34.1


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

end of thread, other threads:[~2025-09-12 17:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-12 15:01 [PATCH] drivers/dma: replace dma_free_coherent with dma_free_wc Zilin Guan
2025-09-12 17:06 ` Markus Elfring

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.