summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mm/memory.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/mm/memory.c b/mm/memory.c
index bb0d3ebcde1f..6c1bd65af03f 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -1475,8 +1475,11 @@ static int insert_page_into_pte_locked(struct mm_struct *mm, pte_t *pte,
static int insert_page_in_batch_locked(struct mm_struct *mm, pmd_t *pmd,
unsigned long addr, struct page *page, pgprot_t prot)
{
- const int err = validate_page_before_insert(page);
+ int err;
+ if (!page_count(page))
+ return -EINVAL;
+ err = validate_page_before_insert(page);
return err ? err : insert_page_into_pte_locked(
mm, pte_offset_map(pmd, addr), addr, page, prot);
}