diff --git a/mm/page_alloc.c b/mm/page_alloc.c index b7f14a4..fc8b544 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -436,6 +436,14 @@ static void __free_pages_ok(struct page mutex_debug_check_no_locks_freed(page_address(page), PAGE_SIZE<mapping != NULL) | (page_count(page) != 0) | @@ -539,7 +556,21 @@ static int prep_new_page(struct page *pa 1 << PG_referenced | 1 << PG_arch_1 | 1 << PG_checked | 1 << PG_mappedtodisk); set_page_private(page, 0); + set_page_refcounted(page); + +#ifndef CONFIG_MMU + if (!(gfp_flags & __GFP_COMP)) { + /* + * Reference all the pages for this order, otherwise if + * anyone accesses one of the pages with (get/put) it + * will be freed. - eg: access_process_vm() + */ + for (i = 1; i < (1 << order); i++) + set_page_refcounted(page + i); + } +#endif + kernel_map_pages(page, 1 << order, 1); if (gfp_flags & __GFP_ZERO)