LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] dma-debug: use virt_addr_valid() to check linear addresses
@ 2017-11-22  3:17 miles.chen
  2017-11-23  8:58 ` Christoph Hellwig
  0 siblings, 1 reply; 3+ messages in thread
From: miles.chen @ 2017-11-22  3:17 UTC (permalink / raw)
  To: Christoph Hellwig, Marek Szyprowski, Robin Murphy
  Cc: linux-kernel, iommu, linux-mediatek, wsd_upstream, Miles Chen

From: Miles Chen <miles.chen@mediatek.com>

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().

Signed-off-by: Miles Chen <miles.chen@mediatek.com>
---
 lib/dma-debug.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/dma-debug.c b/lib/dma-debug.c
index 1b34d21..4c08eb6 100644
--- a/lib/dma-debug.c
+++ b/lib/dma-debug.c
@@ -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))
-- 
1.9.1

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] dma-debug: use virt_addr_valid() to check linear addresses
  2017-11-22  3:17 [PATCH] dma-debug: use virt_addr_valid() to check linear addresses miles.chen
@ 2017-11-23  8:58 ` Christoph Hellwig
  2017-11-23  9:05   ` Miles Chen
  0 siblings, 1 reply; 3+ messages in thread
From: Christoph Hellwig @ 2017-11-23  8:58 UTC (permalink / raw)
  To: miles.chen
  Cc: Christoph Hellwig, Marek Szyprowski, Robin Murphy, linux-kernel,
	iommu, linux-mediatek, wsd_upstream

Can you just resend the original patch with the fixes?

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] dma-debug: use virt_addr_valid() to check linear addresses
  2017-11-23  8:58 ` Christoph Hellwig
@ 2017-11-23  9:05   ` Miles Chen
  0 siblings, 0 replies; 3+ messages in thread
From: Miles Chen @ 2017-11-23  9:05 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Marek Szyprowski, Robin Murphy, linux-kernel, iommu,
	linux-mediatek, wsd_upstream

On Thu, 2017-11-23 at 09:58 +0100, Christoph Hellwig wrote:
> Can you just resend the original patch with the fixes?
> 
No problem. I'll resend the original patch with this fix.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-11-23  9:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-22  3:17 [PATCH] dma-debug: use virt_addr_valid() to check linear addresses miles.chen
2017-11-23  8:58 ` Christoph Hellwig
2017-11-23  9:05   ` Miles Chen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).