aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiaohe Lin <[email protected]>2022-07-09 17:26:29 +0800
committerakpm <[email protected]>2022-07-18 15:07:52 -0700
commitda9a298f5fad0dc615079a340da42928bc5b138e (patch)
treedf3eca8f7d0b0237fd1b3b45d3425acfe85baaee
parentbdeb77bc2c405fa9f954c20269db175a0bd2793f (diff)
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: 8cc5fcbb5be8 ("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]>
-rw-r--r--mm/hugetlb.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index baf7f6b19ce6..a18c071c294e 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -5952,6 +5952,7 @@ int hugetlb_mcopy_atomic_pte(struct mm_struct *dst_mm,
page = alloc_huge_page(dst_vma, dst_addr, 0);
if (IS_ERR(page)) {
+ put_page(*pagep);
ret = -ENOMEM;
*pagep = NULL;
goto out;