diff --git a/mm/memory-failure.c b/mm/memory-failure.c index ceb0c7f1932f2e..6a7f9cab4ddb71 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -936,6 +936,16 @@ static int hwpoison_user_mappings(struct page *p, unsigned long pfn, BUG_ON(!PageHWPoison(p)); return SWAP_FAIL; } + /* + * We pinned the head page for hwpoison handling, + * now we split the thp and we are interested in + * the hwpoisoned raw page, so move the refcount + * to it. + */ + if (hpage != p) { + put_page(hpage); + get_page(p); + } /* THP is split, so ppage should be the real poisoned page. */ ppage = p; }