Skip to content

Commit da9a298

Browse files
MiaoheLinakpm00
authored andcommitted
hugetlb: fix memoryleak in hugetlb_mcopy_atomic_pte
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/[email protected] Fixes: 8cc5fcb ("mm, hugetlb: fix racy resv_huge_pages underflow on UFFDIO_COPY") Signed-off-by: Miaohe Lin <[email protected]> Acked-by: Muchun Song <[email protected]> Reviewed-by: Anshuman Khandual <[email protected]> Reviewed-by: Baolin Wang <[email protected]> Reviewed-by: Mike Kravetz <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent bdeb77b commit da9a298

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

mm/hugetlb.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5952,6 +5952,7 @@ int hugetlb_mcopy_atomic_pte(struct mm_struct *dst_mm,
59525952

59535953
page = alloc_huge_page(dst_vma, dst_addr, 0);
59545954
if (IS_ERR(page)) {
5955+
put_page(*pagep);
59555956
ret = -ENOMEM;
59565957
*pagep = NULL;
59575958
goto out;

0 commit comments

Comments
 (0)