Commit 0bf598d863e3c741d47e3178d645f04c9d6c186c

Authored by Naoya Horiguchi
Committed by Linus Torvalds
1 parent 9809494578

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>

Showing 1 changed file with 5 additions and 3 deletions Side-by-side Diff

... ... @@ -1196,12 +1196,14 @@
1196 1196 break;
1197 1197 vma = vma->vm_next;
1198 1198 }
  1199 + /*
  1200 + * queue_pages_range() confirms that @page belongs to some vma,
  1201 + * so vma shouldn't be NULL.
  1202 + */
  1203 + BUG_ON(!vma);
1199 1204  
1200 1205 if (PageHuge(page))
1201 1206 return alloc_huge_page_noerr(vma, address, 1);
1202   - /*
1203   - * if !vma, alloc_page_vma() will use task or system default policy
1204   - */
1205 1207 return alloc_page_vma(GFP_HIGHUSER_MOVABLE, vma, address);
1206 1208 }
1207 1209 #else