Skip to contentSkip to conversation

dma-debug: use virt_addr_valid() to check linear addresses

PATCH In review [email protected] 2 participants 3 messages Nov 22, 2017 – Nov 23, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dma-debug: use virt_addr_valid() to check linear addresses

From: Miles Chen <miles.chen-NuS5LvNUpcJWk0Htik3J/[email protected]>

Coverity found that the commit 3aaabbf1c39e ("lib/dma-debug.c:
fix incorrect pfn calculation") uses incorrect API to check if a given address is a linear address.
The condition should be: (as discussed in Christoph's review) if (!is_vmalloc_addr(virt) && !virt_addr_valid(virt)) not
if (!is_vmalloc_addr(virt) && !virt_to_page(virt))

Fix it by using virt_addr_valid() instead of virt_to_page().

---
 lib/dma-debug.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
lib/dma-debug.c +2 -2
index 1b34d21..4c08eb6 100644
@@ -1496,7 +1496,7 @@ void debug_dma_alloc_coherent(struct device *dev, size_t size,
 		return;
 
 	/* handle vmalloc and linear addresses */
-	if (!is_vmalloc_addr(virt) && !virt_to_page(virt))
+	if (!is_vmalloc_addr(virt) && !virt_addr_valid(virt))
 		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))
Signature · 1 line
1.9.1
author
#2 lore raw
Quoted 2 lines · Christoph Hellwig

Can you just resend the original patch with the fixes?

No problem. I'll resend the original patch with this fix.