diff mbox series

[-next] lib/test_hmm: check page after calling xa_untag_pointer()

Message ID 20210526140522.2535643-1-yangyingliang@huawei.com (mailing list archive)
State New, archived
Headers show
Series [-next] lib/test_hmm: check page after calling xa_untag_pointer() | expand

Commit Message

Yang Yingliang May 26, 2021, 2:05 p.m. UTC
Check page after calling xa_untag_pointer() to fix compile warning:
  lib/test_hmm.c:631:16: warning: variable ‘page’ set but not used [-Wunused-but-set-variable]
  631 |   struct page *page;
      |                ^~~~

Fixes: 8b2a105c3794 ("mm: selftests for exclusive device memory")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
 lib/test_hmm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Ralph Campbell May 26, 2021, 7:59 p.m. UTC | #1
On 5/26/21 7:05 AM, Yang Yingliang wrote:

> Check page after calling xa_untag_pointer() to fix compile warning:
>    lib/test_hmm.c:631:16: warning: variable ‘page’ set but not used [-Wunused-but-set-variable]
>    631 |   struct page *page;
>        |                ^~~~
>
> Fixes: 8b2a105c3794 ("mm: selftests for exclusive device memory")
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Reviewed-by: Ralph Campbell <rcampbell@nvidia.com>
diff mbox series

Patch

diff --git a/lib/test_hmm.c b/lib/test_hmm.c
index 74d69f87691e..87db37e51d7b 100644
--- a/lib/test_hmm.c
+++ b/lib/test_hmm.c
@@ -632,7 +632,7 @@  static int dmirror_check_atomic(struct dmirror *dmirror, unsigned long start,
 
 		entry = xa_load(&dmirror->pt, pfn);
 		page = xa_untag_pointer(entry);
-		if (xa_pointer_tag(entry) == DPT_XA_TAG_ATOMIC)
+		if (!page || xa_pointer_tag(entry) == DPT_XA_TAG_ATOMIC)
 			return -EPERM;
 	}