linux/kernel/dma
Lance Richardson 28e8b7406d dma: fix call order in dmam_free_coherent
dmam_free_coherent() frees a DMA allocation, which makes the
freed vaddr available for reuse, then calls devres_destroy()
to remove and free the data structure used to track the DMA
allocation. Between the two calls, it is possible for a
concurrent task to make an allocation with the same vaddr
and add it to the devres list.

If this happens, there will be two entries in the devres list
with the same vaddr and devres_destroy() can free the wrong
entry, triggering the WARN_ON() in dmam_match.

Fix by destroying the devres entry before freeing the DMA
allocation.

Tested:
  kokonut //net/encryption
    http://sponge2/b9145fe6-0f72-4325-ac2f-a84d81075b03

Fixes: 9ac7849e35 ("devres: device resource management")
Signed-off-by: Lance Richardson <rlance@google.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
2024-07-19 07:27:28 +02:00
..
coherent.c dma-mapping: clear dev->dma_mem to NULL after freeing it 2023-12-15 12:32:45 +01:00
contiguous.c mm/cma: drop CONFIG_CMA_DEBUG 2024-02-22 10:24:53 -08:00
debug.c dma-mapping fixes for Linux 6.8 2024-01-18 16:49:34 -08:00
debug.h
direct.c swiotlb: reduce swiotlb pool lookups 2024-07-10 07:59:03 +02:00
direct.h swiotlb: reduce swiotlb pool lookups 2024-07-10 07:59:03 +02:00
dummy.c
Kconfig dma: compile-out DMA sync op calls when not used 2024-05-07 13:29:53 +02:00
Makefile dma-mapping: remove CONFIG_DMA_REMAP 2022-03-03 14:00:57 +03:00
map_benchmark.c dma-mapping: benchmark: Don't starve others when doing the test 2024-07-09 07:48:32 +02:00
mapping.c dma: fix call order in dmam_free_coherent 2024-07-19 07:27:28 +02:00
ops_helpers.c
pool.c mm, treewide: rename MAX_ORDER to MAX_PAGE_ORDER 2024-01-08 15:27:15 -08:00
remap.c dma-remap: use kvmalloc_array/kvfree for larger dma memory remap 2023-06-07 15:06:28 +02:00
swiotlb.c swiotlb: fix kernel-doc description for swiotlb_del_transient 2024-07-13 07:36:10 +02:00