diff options
author | Akinobu Mita <akinobu.mita@gmail.com> | 2009-09-21 17:01:47 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-09-22 07:17:30 -0700 |
commit | 945a11136ebdfa7fcce319ee6215958e84cb85f6 (patch) | |
tree | 0553ecd55e5805ea147d6a0f6eae0686d5630cf5 | |
parent | a26f5320c4ee3d46a0da48fa0f3ac6a00b575793 (diff) | |
download | linux-stable-945a11136ebdfa7fcce319ee6215958e84cb85f6.tar.gz linux-stable-945a11136ebdfa7fcce319ee6215958e84cb85f6.tar.bz2 linux-stable-945a11136ebdfa7fcce319ee6215958e84cb85f6.zip |
mm: add gfp mask checking for __get_free_pages()
__get_free_pages() with __GFP_HIGHMEM is not safe because the return
address cannot represent a highmem page. get_zeroed_page() already has
such a debug checking.
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | mm/page_alloc.c | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/mm/page_alloc.c b/mm/page_alloc.c index afda8fd16484..81926c7ef6f0 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -1922,31 +1922,25 @@ EXPORT_SYMBOL(__alloc_pages_nodemask); */ unsigned long __get_free_pages(gfp_t gfp_mask, unsigned int order) { - struct page * page; + struct page *page; + + /* + * __get_free_pages() returns a 32-bit address, which cannot represent + * a highmem page + */ + VM_BUG_ON((gfp_mask & __GFP_HIGHMEM) != 0); + page = alloc_pages(gfp_mask, order); if (!page) return 0; return (unsigned long) page_address(page); } - EXPORT_SYMBOL(__get_free_pages); unsigned long get_zeroed_page(gfp_t gfp_mask) { - struct page * page; - - /* - * get_zeroed_page() returns a 32-bit address, which cannot represent - * a highmem page - */ - VM_BUG_ON((gfp_mask & __GFP_HIGHMEM) != 0); - - page = alloc_pages(gfp_mask | __GFP_ZERO, 0); - if (page) - return (unsigned long) page_address(page); - return 0; + return __get_free_pages(gfp_mask | __GFP_ZERO, 0); } - EXPORT_SYMBOL(get_zeroed_page); void __pagevec_free(struct pagevec *pvec) |