Skip to content

Commit 0bf598d

Browse files
Naoya Horiguchitorvalds
authored andcommitted
mbind: add BUG_ON(!vma) in new_vma_page()
new_vma_page() is called only by page migration called from do_mbind(), where pages to be migrated are queued into a pagelist by queue_pages_range(). queue_pages_range() confirms that a queued page belongs to some vma, so !vma case is not supposed to be happen. This patch adds BUG_ON() to catch this unexpected case. Signed-off-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com> Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 9809494 commit 0bf598d

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

mm/mempolicy.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1196,12 +1196,14 @@ static struct page *new_vma_page(struct page *page, unsigned long private, int *
11961196
break;
11971197
vma = vma->vm_next;
11981198
}
1199+
/*
1200+
* queue_pages_range() confirms that @page belongs to some vma,
1201+
* so vma shouldn't be NULL.
1202+
*/
1203+
BUG_ON(!vma);
11991204

12001205
if (PageHuge(page))
12011206
return alloc_huge_page_noerr(vma, address, 1);
1202-
/*
1203-
* if !vma, alloc_page_vma() will use task or system default policy
1204-
*/
12051207
return alloc_page_vma(GFP_HIGHUSER_MOVABLE, vma, address);
12061208
}
12071209
#else

0 commit comments

Comments
 (0)