From patchwork Thu Aug 18 13:00:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12947995 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 5CB26C00140 for ; Thu, 18 Aug 2022 21:36:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E54758D0002; Thu, 18 Aug 2022 17:36:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E03908D0001; Thu, 18 Aug 2022 17:36:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CF1DC8D0002; Thu, 18 Aug 2022 17:36:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id C1C6C8D0001 for ; Thu, 18 Aug 2022 17:36:09 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 7E0A880935 for ; Thu, 18 Aug 2022 21:36:09 +0000 (UTC) X-FDA: 79814021658.25.5F305F9 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf30.hostedemail.com (Postfix) with ESMTP id DD87F8023B for ; Thu, 18 Aug 2022 21:34:40 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.56]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4M7lKC5p4Zz1N7NB; 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 2/6] mm, hwpoison: fix page refcnt leaking in unpoison_memory() Date: Thu, 18 Aug 2022 21:00:12 +0800 Message-ID: <20220818130016.45313-3-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 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 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1660858482; 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=1OjdLUuBjYrEgtjJJceoQofT/MiEpel7UFPZP2APbeQ=; b=JeXnbDDGFSgWV7YEux244DSGsmZepfzr7i1se91+KjFMP02FBc6r467RNFrY1uuGw1WDTN plx3yovqqMhk0K24vY6hukgh3BVBDKRSUAiZ+kZWA40UDpeE4AAOFiFE/6UMtlEKbR+uU4 du3Om3z+tRjg1+E+dGrmBcjvxaZqFdk= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf30.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1660858482; a=rsa-sha256; cv=none; b=fIjnk2B12enq9Tzi7J3ImHuQ6SImJvGG/KcGW4jdAq+9wOFyOkg0dKdhGC0Z+LbfmascZL A/Hk7V1DVaUKej9bHaFHrLgMKixiBvWnH2gPMvrdPOIVxahppHPPZwRavzIZ6Ckw6Cn3Lq XdWbP5VtfyaubAczwHumEgj68J6mL+w= Authentication-Results: imf30.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf30.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: DD87F8023B X-Stat-Signature: nw61cmfry1eqt8753yfzs6gzj355n8ad X-Rspam-User: X-HE-Tag: 1660858480-435947 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 free_raw_hwp_pages() fails its work, the refcnt of the hugetlb page would have been incremented if ret > 0. Using put_page() to fix refcnt leaking in this case. Fixes: debb6b9c3fdd ("mm, hwpoison: make unpoison aware of raw error info in hwpoisoned hugepage") Signed-off-by: Miaohe Lin Acked-by: Naoya Horiguchi --- mm/memory-failure.c | 1 + 1 file changed, 1 insertion(+) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 22840cd5fe59..0c5ad7505b99 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -2378,6 +2378,7 @@ int unpoison_memory(unsigned long pfn) count = free_raw_hwp_pages(page, false); if (count == 0) { ret = -EBUSY; + put_page(page); goto unlock_mutex; } }