This is a note to let you know that I've just added the patch titled hugetlb: fix memoryleak in hugetlb_mcopy_atomic_pte to the 5.18-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: hugetlb-fix-memoryleak-in-hugetlb_mcopy_atomic_pte.patch and it can be found in the queue-5.18 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From da9a298f5fad0dc615079a340da42928bc5b138e Mon Sep 17 00:00:00 2001 From: Miaohe Lin <linmiaohe@xxxxxxxxxx> Date: Sat, 9 Jul 2022 17:26:29 +0800 Subject: hugetlb: fix memoryleak in hugetlb_mcopy_atomic_pte From: Miaohe Lin <linmiaohe@xxxxxxxxxx> commit da9a298f5fad0dc615079a340da42928bc5b138e upstream. When alloc_huge_page fails, *pagep is set to NULL without put_page first. So the hugepage indicated by *pagep is leaked. Link: https://lkml.kernel.org/r/20220709092629.54291-1-linmiaohe@xxxxxxxxxx Fixes: 8cc5fcbb5be8 ("mm, hugetlb: fix racy resv_huge_pages underflow on UFFDIO_COPY") Signed-off-by: Miaohe Lin <linmiaohe@xxxxxxxxxx> Acked-by: Muchun Song <songmuchun@xxxxxxxxxxxxx> Reviewed-by: Anshuman Khandual <anshuman.khandual@xxxxxxx> Reviewed-by: Baolin Wang <baolin.wang@xxxxxxxxxxxxxxxxx> Reviewed-by: Mike Kravetz <mike.kravetz@xxxxxxxxxx> Cc: <stable@xxxxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- mm/hugetlb.c | 1 + 1 file changed, 1 insertion(+) --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -5827,6 +5827,7 @@ int hugetlb_mcopy_atomic_pte(struct mm_s page = alloc_huge_page(dst_vma, dst_addr, 0); if (IS_ERR(page)) { + put_page(*pagep); ret = -ENOMEM; *pagep = NULL; goto out; Patches currently in stable-queue which might be from linmiaohe@xxxxxxxxxx are queue-5.18/hugetlb-fix-memoryleak-in-hugetlb_mcopy_atomic_pte.patch queue-5.18/mm-hugetlb-separate-path-for-hwpoison-entry-in-copy_hugetlb_page_range.patch