Commit 787af64d authored by Zi Yan's avatar Zi Yan Committed by Linus Torvalds

mm: page_alloc: validate buddy before check its migratetype.

Whenever a buddy page is found, page_is_buddy() should be called to
check its validity.  Add the missing check during pageblock merge check.

Fixes: 1dd214b8 ("mm: page_alloc: avoid merging non-fallbackable pageblocks with others")
Link: https://lore.kernel.org/all/20220330154208.71aca532@gandalf.local.home/Reported-and-tested-by: default avatarSteven Rostedt <rostedt@goodmis.org>
Signed-off-by: default avatarZi Yan <ziy@nvidia.com>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent d5fd43ba
...@@ -1108,6 +1108,9 @@ static inline void __free_one_page(struct page *page, ...@@ -1108,6 +1108,9 @@ static inline void __free_one_page(struct page *page,
buddy_pfn = __find_buddy_pfn(pfn, order); buddy_pfn = __find_buddy_pfn(pfn, order);
buddy = page + (buddy_pfn - pfn); buddy = page + (buddy_pfn - pfn);
if (!page_is_buddy(page, buddy, order))
goto done_merging;
buddy_mt = get_pageblock_migratetype(buddy); buddy_mt = get_pageblock_migratetype(buddy);
if (migratetype != buddy_mt if (migratetype != buddy_mt
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment