[PATCH] mm: Avoid a risk of null pointer.

jiping huang posted 1 patch 1 year, 5 months ago
[PATCH] mm: Avoid a risk of null pointer.
Posted by jiping huang 1 year, 5 months ago
There is a probability that we will get a null pointer when we use
find_vm() interface.

Signed-off-by: jiping huang <huangjiping95@qq.com>

diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index aec756ae5637..a0bcc1865c62 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -1079,6 +1079,11 @@ static long migrate_to_node(struct mm_struct *mm, int source, int dest,
 	mmap_read_lock(mm);
 	vma = find_vma(mm, 0);
 
+	if (!vma) {
+		mmap_read_unlock(mm);
+		return -EFAULT;
+	}
+
 	/*
 	 * This does not migrate the range, but isolates all pages that
 	 * need migration.  Between passing in the full user address
-- 
2.34.1