From patchwork Tue Aug 23 03:23:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12951675 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id E0418C32789 for ; Tue, 23 Aug 2022 03:24:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C4A188D0003; Mon, 22 Aug 2022 23:24:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BFA258D0001; Mon, 22 Aug 2022 23:24:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AC8768D0003; Mon, 22 Aug 2022 23:24:23 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id A325E8D0001 for ; Mon, 22 Aug 2022 23:24:23 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 7BBAC121364 for ; Tue, 23 Aug 2022 03:24:23 +0000 (UTC) X-FDA: 79829414406.10.AA04DCF Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf23.hostedemail.com (Postfix) with ESMTP id 075D4140029 for ; Tue, 23 Aug 2022 03:24:22 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4MBZHl13FYzgYpg; Tue, 23 Aug 2022 11:20:51 +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; Tue, 23 Aug 2022 11:24:19 +0800 From: Miaohe Lin To: , CC: , , Subject: [PATCH v2 1/6] mm, hwpoison: fix page refcnt leaking in try_memory_failure_hugetlb() Date: Tue, 23 Aug 2022 11:23:41 +0800 Message-ID: <20220823032346.4260-2-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220823032346.4260-1-linmiaohe@huawei.com> References: <20220823032346.4260-1-linmiaohe@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1661225063; a=rsa-sha256; cv=none; b=SlgpeFV+PIyUnfM0d7P9eAth0OOZI3uZi8d6dtDud+zOfEapmAIolrWegT8qNTOyGpIso7 NrWTRXV7BYJzdbF1xDGGuWBx4gVVgwMz8iaWWf7ZOiGPyoMNd0N4Ee1/NnvsWnz4fQbHen zotc3NkFlwt3lGqKN2dEQg/uji01YtA= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=none; spf=pass (imf23.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1661225063; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Oh2/RQVPb2yPdIcXlpkFYi8DjgX39Qn6ZDFEyN9n/F4=; b=E2HvrJ6JWRp/Fj2SP0gn9YjtRUuRCwouU50fbAlJ2byUasfDL1cKecutKSL9qRD4uzk4ac BA1lvxmyfvnjA+2L3kMnpOGfin17NhhlDz4H44x4UDtOOp4PY8bYV/50e1OrDDYmlx4CHA rGogwSwfuTJ1lj2Kr4YdNpcLG9gJTb8= X-Rspamd-Queue-Id: 075D4140029 X-Rspam-User: Authentication-Results: imf23.hostedemail.com; dkim=none; spf=pass (imf23.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com X-Rspamd-Server: rspam01 X-Stat-Signature: 7khstsjfe444p3dba99b3rcnrpd1ck4h X-HE-Tag: 1661225062-901154 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: When hwpoison_filter() refuses to hwpoison a hugetlb page, the refcnt of the page would have been incremented if res == 1. Using put_page() to fix the refcnt leaking in this case. Fixes: 405ce051236c ("mm/hwpoison: fix race between hugetlb free/demotion and 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 5b368124956d..9d1ebfef04ee 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 if (hwpoison_filter(p)) { hugetlb_clear_page_hwpoison(head); - res = -EOPNOTSUPP; - goto out; + unlock_page(head); + if (res == 1) + put_page(head); + return -EOPNOTSUPP; } /*