diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 6e60657875d328..b2877a84ed19c0 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -5640,9 +5640,12 @@ EXPORT_SYMBOL(get_zeroed_page); */ void __free_pages(struct page *page, unsigned int order) { + /* get PageHead before we drop reference */ + int head = PageHead(page); + if (put_page_testzero(page)) free_the_page(page, order); - else if (!PageHead(page)) + else if (!head) while (order-- > 0) free_the_page(page + (1 << order), order); }