From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4729BC433EF for ; Tue, 12 Jul 2022 08:13:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232471AbiGLINM (ORCPT ); Tue, 12 Jul 2022 04:13:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232482AbiGLINF (ORCPT ); Tue, 12 Jul 2022 04:13:05 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3F3E39B19D for ; Tue, 12 Jul 2022 01:13:03 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 6F4891516; Tue, 12 Jul 2022 01:13:03 -0700 (PDT) Received: from [10.162.42.8] (unknown [10.162.42.8]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A4F973F73D; Tue, 12 Jul 2022 01:13:00 -0700 (PDT) Message-ID: <520e487b-a274-9b92-b01b-164ee9a2b6c3@arm.com> Date: Tue, 12 Jul 2022 13:42:56 +0530 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [PATCH] hugetlb: fix memoryleak in hugetlb_mcopy_atomic_pte Content-Language: en-US To: Miaohe Lin , akpm@linux-foundation.org, mike.kravetz@oracle.com, songmuchun@bytedance.com Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20220709092629.54291-1-linmiaohe@huawei.com> From: Anshuman Khandual In-Reply-To: <20220709092629.54291-1-linmiaohe@huawei.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 7/9/22 14:56, Miaohe Lin wrote: > When alloc_huge_page fails, *pagep is set to NULL without put_page first. > So the hugepage indicated by *pagep is leaked. > > Fixes: 8cc5fcbb5be8 ("mm, hugetlb: fix racy resv_huge_pages underflow on UFFDIO_COPY") > Signed-off-by: Miaohe Lin Reviewed-by: Anshuman Khandual > --- > mm/hugetlb.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/mm/hugetlb.c b/mm/hugetlb.c > index 06c2d86b1ba3..598c37279fee 100644 > --- a/mm/hugetlb.c > +++ b/mm/hugetlb.c > @@ -5962,6 +5962,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;