Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4091652imw; Tue, 12 Jul 2022 01:21:34 -0700 (PDT) X-Google-Smtp-Source: AGRyM1v4A42SgfedyqHzz1IImZzJsiu1DJ2gILRjmIK30mTPnQ151754N64epEqqXBGQqhuTnXvJ X-Received: by 2002:a17:906:6a0f:b0:72b:64ce:289d with SMTP id qw15-20020a1709066a0f00b0072b64ce289dmr6290971ejc.663.1657614093820; Tue, 12 Jul 2022 01:21:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657614093; cv=none; d=google.com; s=arc-20160816; b=YWbYvt4BmazL47/nQRnXku1+oXu5nODBU0lxnGe1JtlPRzxPVOplTWEuQwV71ytHbB LDlbAtMFHUTpaM58kVJcp9SmCpc+A4Btm0BCWdVSJQYz8Tj6HCGuaht0Kl5m8Xzp4+MY NHcEYOwkAT4+3JhqGJSIN0wfMptkfvjwhBBdJDq6RdNs1Yh3FLiUWl73YKAUhhBrdmom UtBAlqm6YUHjTeLF7ehMvYshZBL75Sg16LUXTpmBCI6cScGQdC0pAiH4H7vDZYXaQ2zj zT6M548nSfU4Cx6tVg9koGHS/u44EP07feVK2SNjnZskxIjjSGQ/ueeyjEy+71HLuL8Q 6Mjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=gXgXKINvCz/zc7AFNavq3Aumvr8bGnCxLGQmretaSDI=; b=Ncmv8Cs8QbcGDJJe7IL/3eGja25bb1aI+fcOJ5t5hQKYaWrzDyTJKuOsbvkySRhoI7 Qf1FUASl+jVP8jmqPrKBixK6L9HT2+maxh+bQXEqKY6XUaxZcDJ1p3HId0JjsLJksfFY WCW3D5inc1H3oY8iskAUfcjq0gCvQvh6kajIZGXnSjFuFLywRI/8pUuRcfYeUqidVj4i +vaQ7OUKCRDWbIrveUTbZ4Izn0gseXisgI7iLDf4zqCre3GNnaWvN32Ar9vnmOko61eV NXrVpq4HKQfiYU8c+hyY1zJdSna0o0s0VnIJUfpmq2xAiB+vWs6pvcATzU/h9U++/SYS F5rA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m11-20020aa7c48b000000b0043a14627b43si11921030edq.491.2022.07.12.01.21.07; Tue, 12 Jul 2022 01:21:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232489AbiGLINM (ORCPT + 99 others); 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 X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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;