dma-debug: fix memory leak in debug_dma_alloc_coherent
authorMiles Chen <miles.chen@mediatek.com>
Thu, 22 Feb 2018 11:22:20 +0000 (19:22 +0800)
committerChristoph Hellwig <hch@lst.de>
Thu, 22 Feb 2018 23:02:33 +0000 (15:02 -0800)
commitaf1da686843750809738c01e153320106e890804
treeed3a996f8f9dce16a0ba24b015a1e16bea5920c1
parenta638af00b27266c09ab7ac69141e6f4ac6c00eff
dma-debug: fix memory leak in debug_dma_alloc_coherent

Marty reported a memory leakage introduced by commit 3aaabbf1c39e
("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>
lib/dma-debug.c