Skip to content

Commit 787af64

Browse files
x-y-ztorvalds
authored andcommitted
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: 1dd214b ("mm: page_alloc: avoid merging non-fallbackable pageblocks with others") Link: https://lore.kernel.org/all/[email protected]/ Reported-and-tested-by: Steven Rostedt <[email protected]> Signed-off-by: Zi Yan <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent d5fd43b commit 787af64

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

mm/page_alloc.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,6 +1108,9 @@ static inline void __free_one_page(struct page *page,
11081108

11091109
buddy_pfn = __find_buddy_pfn(pfn, order);
11101110
buddy = page + (buddy_pfn - pfn);
1111+
1112+
if (!page_is_buddy(page, buddy, order))
1113+
goto done_merging;
11111114
buddy_mt = get_pageblock_migratetype(buddy);
11121115

11131116
if (migratetype != buddy_mt

0 commit comments

Comments
 (0)