Skip to content

Commit b07bc23

Browse files
Joakim ZhangChristoph Hellwig
authored andcommitted
dma-mapping: clear dev->dma_mem to NULL after freeing it
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: cf65a0f ("dma-mapping: move all DMA mapping code to kernel/dma") Signed-off-by: Joakim Zhang <joakim.zhang@cixtech.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
1 parent 55c5438 commit b07bc23

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

kernel/dma/coherent.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,10 @@ int dma_declare_coherent_memory(struct device *dev, phys_addr_t phys_addr,
132132

133133
void dma_release_coherent_memory(struct device *dev)
134134
{
135-
if (dev)
135+
if (dev) {
136136
_dma_release_coherent_memory(dev->dma_mem);
137+
dev->dma_mem = NULL;
138+
}
137139
}
138140

139141
static void *__dma_alloc_from_coherent(struct device *dev,

0 commit comments

Comments
 (0)