From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751617AbdKVDRx (ORCPT ); Tue, 21 Nov 2017 22:17:53 -0500 Received: from mailgw01.mediatek.com ([210.61.82.183]:61601 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1751458AbdKVDRv (ORCPT ); Tue, 21 Nov 2017 22:17:51 -0500 X-UUID: a22e983644be4f5da5397e0a11f8439f-20171122 From: To: Christoph Hellwig , Marek Szyprowski , Robin Murphy CC: , , , , Miles Chen Subject: [PATCH] dma-debug: use virt_addr_valid() to check linear addresses Date: Wed, 22 Nov 2017 11:17:35 +0800 Message-ID: <1511320655-22752-1-git-send-email-miles.chen@mediatek.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Miles Chen 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 --- 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