From nobody Sat Apr 11 00:44:28 2026 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 DF1FBC00140 for ; Thu, 18 Aug 2022 13:00:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244853AbiHRNAq (ORCPT ); Thu, 18 Aug 2022 09:00:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242589AbiHRNAo (ORCPT ); Thu, 18 Aug 2022 09:00:44 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4514A647D8 for ; Thu, 18 Aug 2022 06:00:43 -0700 (PDT) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.56]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4M7lKC2kMdz1N7Hm; Thu, 18 Aug 2022 20:57:19 +0800 (CST) Received: from huawei.com (10.175.124.27) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Thu, 18 Aug 2022 21:00:41 +0800 From: Miaohe Lin To: , CC: , , Subject: [PATCH 1/6] mm, hwpoison: fix page refcnt leaking in try_memory_failure_hugetlb() Date: Thu, 18 Aug 2022 21:00:11 +0800 Message-ID: <20220818130016.45313-2-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220818130016.45313-1-linmiaohe@huawei.com> References: <20220818130016.45313-1-linmiaohe@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" When hwpoison_filter() refuses to hwpoison a hugetlb page, the refcnt of the page would have been incremented if res =3D=3D 1. Using put_page() to f= ix the refcnt leaking in this case. Fixes: 405ce051236c ("mm/hwpoison: fix race between hugetlb free/demotion a= nd memory_failure_hugetlb()") Signed-off-by: Miaohe Lin Acked-by: Naoya Horiguchi --- mm/memory-failure.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index e48f6f6a259d..22840cd5fe59 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -1860,8 +1860,10 @@ static int try_memory_failure_hugetlb(unsigned long = pfn, int flags, int *hugetlb =20 if (hwpoison_filter(p)) { hugetlb_clear_page_hwpoison(head); - res =3D -EOPNOTSUPP; - goto out; + unlock_page(head); + if (res =3D=3D 1) + put_page(head); + return -EOPNOTSUPP; } =20 /* --=20 2.23.0