dma-mapping: clear dev->dma_mem to NULL after freeing it
authorJoakim Zhang <joakim.zhang@cixtech.com>
Thu, 14 Dec 2023 08:25:26 +0000 (16:25 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 25 Jan 2024 23:35:26 +0000 (15:35 -0800)
commit849ca053beb0372ad3ef4c3a15eb511bcb461691
tree4db26277a4e282219342e803b89d9da649c1d88c
parent94e5f64283a16d6b9eda82e0ebb9ec477a6c2ef6
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@cixtech.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
kernel/dma/coherent.c