mirror of
https://github.com/FEX-Emu/linux.git
synced 2024-12-14 04:41:26 +00:00
dma-debug: fix memory leak in debug_dma_alloc_coherent
Marty reported a memory leakage introduced by commit3aaabbf1c3
("lib/dma-debug.c: fix incorrect pfn calculation"). Fix it by checking the virtual address before allocating the entry. This patch also use virt_addr_valid() instead of virt_to_page() to check if a virtual address is linear. Fixes:3aaabbf1
("lib/dma-debug.c: fix incorrect pfn calculation") Reported-by: Marty Faltesek <mfaltesek@google.com> Signed-off-by: Miles Chen <miles.chen@mediatek.com> Acked-by: Robin Murphy <robin.murphy@arm.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
This commit is contained in:
parent
a638af00b2
commit
af1da68684
@ -1491,12 +1491,12 @@ void debug_dma_alloc_coherent(struct device *dev, size_t size,
|
||||
if (unlikely(virt == NULL))
|
||||
return;
|
||||
|
||||
entry = dma_entry_alloc();
|
||||
if (!entry)
|
||||
/* handle vmalloc and linear addresses */
|
||||
if (!is_vmalloc_addr(virt) && !virt_addr_valid(virt))
|
||||
return;
|
||||
|
||||
/* handle vmalloc and linear addresses */
|
||||
if (!is_vmalloc_addr(virt) && !virt_to_page(virt))
|
||||
entry = dma_entry_alloc();
|
||||
if (!entry)
|
||||
return;
|
||||
|
||||
entry->type = dma_debug_coherent;
|
||||
@ -1528,7 +1528,7 @@ void debug_dma_free_coherent(struct device *dev, size_t size,
|
||||
};
|
||||
|
||||
/* handle vmalloc and linear addresses */
|
||||
if (!is_vmalloc_addr(virt) && !virt_to_page(virt))
|
||||
if (!is_vmalloc_addr(virt) && !virt_addr_valid(virt))
|
||||
return;
|
||||
|
||||
if (is_vmalloc_addr(virt))
|
||||
|
Loading…
Reference in New Issue
Block a user