From patchwork Sat Jul 15 03:17:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 13314366 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 CF83AC001E0 for ; Sat, 15 Jul 2023 03:17:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 925D58D0001; Fri, 14 Jul 2023 23:17:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8D4066B0078; Fri, 14 Jul 2023 23:17:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7C28C8D0001; Fri, 14 Jul 2023 23:17:27 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 6BADA6B0075 for ; Fri, 14 Jul 2023 23:17:27 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 40AA3C0223 for ; Sat, 15 Jul 2023 03:17:27 +0000 (UTC) X-FDA: 81012385734.19.FBFC778 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf18.hostedemail.com (Postfix) with ESMTP id 8A92A1C000D for ; Sat, 15 Jul 2023 03:17:24 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=none; spf=pass (imf18.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=1689391045; 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=m0sydhJCuR1Xxpd1jnmiNRMyod07FiDhIP+UyRnnN9I=; b=KaWPXJSKxgkG2DZ6vLTXb208u+KzaGeC7rbxJJLB82D8ie6l0YvegDWtLMNF0hR1uBxpcU fqCM3e+CG6Vxi38y8qBKcCVguDu7GEch4Mb843F2fctj/PRwPYNAU0o9i91ZjaP/BqWIZH V2xGNP5wzFF2PNv602mbJOBJfBT108Q= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689391045; a=rsa-sha256; cv=none; b=Fnpu3frmLvOFb1E4s29gxbSbEdMBKRQjk6JVAGmMbjt1ZON8KaJNi8o0P4dGleD74nXRV3 UQ7Yx6C3Awu+pV+4QL4u2c48wue+CY+bkneBEGrBI/9bpy4gcCVtRFEAb5PEfIKDY9N0WB jCeE4LmwaPkanL9Zf5UgTgKcxzzxBSk= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=none; spf=pass (imf18.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 Received: from canpemm500002.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4R2tjk2f2VztRB3; Sat, 15 Jul 2023 11:14:18 +0800 (CST) Received: from huawei.com (10.174.151.185) 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.2507.27; Sat, 15 Jul 2023 11:17:20 +0800 From: Miaohe Lin To: , CC: , , , Subject: [PATCH 2/4] mm: memory-failure: fix potential unexpected return value from unpoison_memory() Date: Sat, 15 Jul 2023 11:17:27 +0800 Message-ID: <20230715031729.2420338-3-linmiaohe@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230715031729.2420338-1-linmiaohe@huawei.com> References: <20230715031729.2420338-1-linmiaohe@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.174.151.185] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: 8A92A1C000D X-Rspam-User: X-Stat-Signature: xrt17iuq9qxjzo77wo1b4zk4j8rp1fup X-Rspamd-Server: rspam03 X-HE-Tag: 1689391044-840775 X-HE-Meta: U2FsdGVkX1/8Lbeh3WzC75/V9Ua/wIDOIrr9TfSuJsi2lNKEjmzVYy00WYrWfQ6ayZvu5D1YgV6RDTcyG/rDbqpUXRrCosecpWr9e3RbnaBHS80LSgnizA/N3NsG3P5dx+lRAHOmd2sQCuTDrZYtQq42T9ORbAOJMtrbSN12WVd93UbIphib5V5S9qeJ3Li5j2rW2Ug/1NBcbM6kt4Ehunx3RpL6gJdRniZkD4iA8TYE8z8WSZB3Zkx1PCxXZgV4+Lj+d5Zz8I4/XtFYrbpFtqoqI/BKOwTy0gYJBEwup2RvLd0WMnfpwdZ0hTweSSgVJNW4PatrFbILWGkD2cxTytjBe52c8iqSl7ei8b9TN738cQI4XFRvMnYOZje7JYBLW461t8F0fL0SI6S0L9SXMhXxpH+CSLfMxKyW1R5+1tFtAb62/MCHatYrs33lVaCr9Tpko3KHyK5S3uWdQhGXSQyu5kVkWbKHP/JQ5HO+Go8kc0QMuAWiDZw3cF9FoLO7WA9ZdKBxe28U35aw9FraxSMYpyIlllgyypgTuG0HGdhgNfMC8xVliP+m+FSgrJw+DpiZM+HWniYD5TNAJ7ZK3mG/QaPCnEGCZ2Xh8Ivx1deKSQFQZggRjBak5eBqtuSFS9LRFrFjEhdl4Np5g4JGd78wqMGCfqabe8yiPBHdJoa4XsuFeS4kDhuPutEaSx5UqjmaGCAJ3g6xUFpTVge6dBledp2xAYlH0Gt9etKDdx6jkL2oxp7+TTziYHYLVFRhFCo8ncGgPu3zBPjdmPUDqA8wlKV13a0Ye5Yx5U3uvUNPWdqX4S3e8xAZ7Axshtd9kf2oURwQheh/0WYJ0KNwreN8f0g9NditjGUQCmAD0RCY0cUnZR77KPTfrNbUBvnCS3uhb6UP3x3AM3qqrsT8a72JA6Cw58R0qn2DOTZyqGQZ/oZkSi7ZVeig56u97r+ifE+iy64H4GJSs7GcyA9 Sjy7Lz5D Jl0GkUeg8puYVGwnglPdLGQQJ8gltyf0qlsJwghvVqtCmldJDs3DlJt3CbHxPcEVbjLK/06wuN1dRnb+tCtNHg7+WLuC+1UBnTaYhrVWOijaeMNRWc4T58HGRYAxQiRskauYmyfJYUI/wv+ZLT0NxzP0usJq9rEkiwlELXrTKHvsfdsRKF2WVKLVH2J5QlFzCtsie 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: If unpoison_memory() fails to clear page hwpoisoned flag, return value ret is expected to be -EBUSY. But when get_hwpoison_page() returns 1 and fails to clear page hwpoisoned flag due to races, return value will be unexpected 1 leading to users being confused. Fixes: bf181c582588 ("mm/hwpoison: fix unpoison_memory()") Signed-off-by: Miaohe Lin --- mm/memory-failure.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 9ab97016877e..ac074f82f5b3 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -2546,11 +2546,11 @@ int unpoison_memory(unsigned long pfn) unpoison_pr_info("Unpoison: failed to grab page %#lx\n", pfn, &unpoison_rs); } else { + ret = -EBUSY; if (PageHuge(p)) { huge = true; count = folio_free_raw_hwp(folio, false); if (count == 0) { - ret = -EBUSY; folio_put(folio); goto unlock_mutex; }