Patch "dma-mapping: clear dev->dma_mem to NULL after freeing it" has been added to the 6.7-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    dma-mapping: clear dev->dma_mem to NULL after freeing it

to the 6.7-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     dma-mapping-clear-dev-dma_mem-to-null-after-freeing-.patch
and it can be found in the queue-6.7 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 184a06fcdb281137d580b7ca03b5e7c5391b1610
Author: Joakim Zhang <joakim.zhang@xxxxxxxxxxx>
Date:   Thu Dec 14 16:25:26 2023 +0800

    dma-mapping: clear dev->dma_mem to NULL after freeing it
    
    [ Upstream commit b07bc2347672cc8c7293c64499f1488278c5ca3d ]
    
    Reproduced with below sequence:
    dma_declare_coherent_memory()->dma_release_coherent_memory()
    ->dma_declare_coherent_memory()->"return -EBUSY" error
    
    It will return -EBUSY from the dma_assign_coherent_memory()
    in dma_declare_coherent_memory(), the reason is that dev->dma_mem
    pointer has not been set to NULL after it's freed.
    
    Fixes: cf65a0f6f6ff ("dma-mapping: move all DMA mapping code to kernel/dma")
    Signed-off-by: Joakim Zhang <joakim.zhang@xxxxxxxxxxx>
    Signed-off-by: Christoph Hellwig <hch@xxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/kernel/dma/coherent.c b/kernel/dma/coherent.c
index c21abc77c53e..ff5683a57f77 100644
--- a/kernel/dma/coherent.c
+++ b/kernel/dma/coherent.c
@@ -132,8 +132,10 @@ int dma_declare_coherent_memory(struct device *dev, phys_addr_t phys_addr,
 
 void dma_release_coherent_memory(struct device *dev)
 {
-	if (dev)
+	if (dev) {
 		_dma_release_coherent_memory(dev->dma_mem);
+		dev->dma_mem = NULL;
+	}
 }
 
 static void *__dma_alloc_from_coherent(struct device *dev,




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux