Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp3938407imw; Mon, 11 Jul 2022 20:29:38 -0700 (PDT) X-Google-Smtp-Source: AGRyM1u2LYdMvVgu5MIgXYTxbW5m9TbQMHNvKjH/1ZDgeJt0op0QvcG1pfg/ZQQK1/BFEYDwvpMG X-Received: by 2002:a63:2b8c:0:b0:411:954c:1f1f with SMTP id r134-20020a632b8c000000b00411954c1f1fmr17864448pgr.548.1657596577939; Mon, 11 Jul 2022 20:29:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657596577; cv=none; d=google.com; s=arc-20160816; b=irfHmvFfm+i0HawPBDZz00IufnFcSIL+QxOmcK67zSrFtL9yqHuSiwOCQbiqE8I/P0 nhDL/jRUP2dMwfAQG67J/Hm/rh+c+mGkpPTox6BdlynleNJ7bgmbHl/53AG5r7EO2AbO mcb4ptfgadDlT1YZ0ldjdObQv3eX/jx1BLknwolUZ9R8RAIP6C//zEIkArdDlPMIORjG H84SXoWjE35axWSciKHghhkzsAj7UjpvJQZOsUw1mjsI2j3DFMPqe+nQOYfXvzswINPk ql2mVyD1KUvM6O49owK/Zmi2SYeWOg7oX9VuqkaZSSp2umIIoc7Vp2sRfKbI8NKT6wxO +FwA== 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:subject:user-agent:mime-version:date:message-id; bh=vdQ83+o8qtic6jp51nwGcn2rM8y/QYudwrjYrzpCVrM=; b=MwLiNTLupMCX5OEZLb7PsFnOh45YI/sD4CoglbHWSS0ySYa0Dl2Vle51gcX3WG4S1u svPi1205vnSWIjq31JPhILX4EBD91WzZ/H+y+34HTd2Ww7zKz0aL31uje8ev82k0B0sH hYC70L/6ytPKoVqqIzZWEI3DdIHkYuCJKCQEGmHru9yqCNBKgsM5J42QBtd8AVhwjmw/ uCYBjYs29NZVa9ndx6nGUq7yddy5nPt4xb4H6BRDJtbx+tnk+diMixBx9CInBLuqVkph y3889jb4g265/fLENzGzGMRWOtFHFEkDdu39/MfnzoMW6mK02C8kP7cp9QwYT5qv/Hiw zmFw== 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=alibaba.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c5-20020a656745000000b00412ace8b0fdsi12791176pgu.740.2022.07.11.20.29.25; Mon, 11 Jul 2022 20:29:37 -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=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229733AbiGLDA4 (ORCPT + 99 others); Mon, 11 Jul 2022 23:00:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229476AbiGLDAz (ORCPT ); Mon, 11 Jul 2022 23:00:55 -0400 Received: from out30-42.freemail.mail.aliyun.com (out30-42.freemail.mail.aliyun.com [115.124.30.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3B201D0D1 for ; Mon, 11 Jul 2022 20:00:54 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R901e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045170;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=6;SR=0;TI=SMTPD_---0VJ6IizN_1657594851; Received: from 30.97.48.63(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0VJ6IizN_1657594851) by smtp.aliyun-inc.com; Tue, 12 Jul 2022 11:00:52 +0800 Message-ID: <801e4f05-6097-4537-9715-2e00a3990f7d@linux.alibaba.com> Date: Tue, 12 Jul 2022 11:00:55 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH] hugetlb: fix memoryleak in hugetlb_mcopy_atomic_pte 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: Baolin Wang In-Reply-To: <20220709092629.54291-1-linmiaohe@huawei.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL 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/2022 5:26 PM, 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: Baolin Wang > --- > 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;