mm, hwpoison: fix page refcnt leaking in unpoison_memory()

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2184858
Tested: with reproducer and generic tests

commit 6bbabd041dfd4823c752940286656d404621bf38
Author: Miaohe Lin <linmiaohe@huawei.com>
Date:   Thu Aug 18 21:00:12 2022 +0800

    mm, hwpoison: fix page refcnt leaking in unpoison_memory()

    When free_raw_hwp_pages() fails its work, the refcnt of the hugetlb page
    would have been incremented if ret > 0.  Using put_page() to fix refcnt
    leaking in this case.

    Link: https://lkml.kernel.org/r/20220818130016.45313-3-linmiaohe@huawei.com
    Fixes: debb6b9c3fdd ("mm, hwpoison: make unpoison aware of raw error info in hwpoisoned hugepage")
    Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
    Acked-by: Naoya Horiguchi <naoya.horiguchi@nec.com>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

Signed-off-by: Aristeu Rozanski <arozansk@redhat.com>
This commit is contained in:
Aristeu Rozanski 2023-04-18 10:53:47 -04:00
parent b2214bac44
commit ad97a4a927
1 changed files with 1 additions and 0 deletions

View File

@ -2294,6 +2294,7 @@ int unpoison_memory(unsigned long pfn)
count = free_raw_hwp_pages(page, false);
if (count == 0) {
ret = -EBUSY;
put_page(page);
goto unlock_mutex;
}
}