From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-it1-f199.google.com (mail-it1-f199.google.com [209.85.166.199]) by kanga.kvack.org (Postfix) with ESMTP id E55876B000A for ; Tue, 13 Nov 2018 02:00:21 -0500 (EST) Received: by mail-it1-f199.google.com with SMTP id h126-v6so3003797ita.1 for ; Mon, 12 Nov 2018 23:00:21 -0800 (PST) Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id 191-v6sor18570647itu.15.2018.11.12.23.00.20 for (Google Transport Security); Mon, 12 Nov 2018 23:00:20 -0800 (PST) MIME-Version: 1.0 From: Yongkai Wu Date: Tue, 13 Nov 2018 15:00:09 +0800 Message-ID: Subject: [PATCH] mm/hwpoison: fix incorrect call put_hwpoison_page() when isolate_huge_page() return false Content-Type: multipart/alternative; boundary="000000000000ebed07057a865efd" Sender: owner-linux-mm@kvack.org List-ID: To: n-horiguchi@ah.jp.nec.com Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org --000000000000ebed07057a865efd Content-Type: text/plain; charset="UTF-8" when isolate_huge_page() return false,it won't takes a refcount of page, if we call put_hwpoison_page() in that case,we may hit the VM_BUG_ON_PAGE! Signed-off-by: Yongkai Wu --- mm/memory-failure.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 0cd3de3..ed09f56 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -1699,12 +1699,13 @@ static int soft_offline_huge_page(struct page *page, int flags) unlock_page(hpage); ret = isolate_huge_page(hpage, &pagelist); - /* - * get_any_page() and isolate_huge_page() takes a refcount each, - * so need to drop one here. - */ - put_hwpoison_page(hpage); - if (!ret) { + if (ret) { + /* + * get_any_page() and isolate_huge_page() takes a refcount each, + * so need to drop one here. + */ + put_hwpoison_page(hpage); + } else { pr_info("soft offline: %#lx hugepage failed to isolate\n", pfn); return -EBUSY; } -- 1.8.3.1 --000000000000ebed07057a865efd Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
when isolate_huge_page() return fals= e,it won't takes a refcount of page,
if we call put_hwpoison_= page() in that case,we may hit the VM_BUG_ON_PAGE!

Signed-off-by: Yongkai Wu <nic_w@163.c= om>
---
=C2=A0mm/memory-failure.c | 13 +++++++--= ----
=C2=A01 file changed, 7 insertions(+), 6 deletions(-)
<= div>
diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index 0cd3de3..ed09f56 100644
--- a/mm/memory-failure.c<= /div>
+++ b/mm/memory-failure.c
@@ -1699,12 +1699,13 @@ stati= c int soft_offline_huge_page(struct page *page, int flags)
=C2=A0= unlock_page(hpage);
=C2= =A0
=C2=A0 ret =3D isolate= _huge_page(hpage, &pagelist);
- /*
- * get_any_= page() and isolate_huge_page() takes a refcount each,
- * so need to drop one here.
- */
- put_hwpoison_page(hpage);
- if (!ret) {
+ if (ret) {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 /*
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 * get_any_page() and isolate_huge_page() = takes a refcount each,
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 * so need to drop one here.
+= =C2=A0 =C2=A0 =C2=A0 =C2=A0 */
+ put_hwpoison_page(hpage);<= /div>
+ } else {
=C2= =A0 pr_info("soft offline: %#l= x hugepage failed to isolate\n", pfn);
=C2=A0 return -EBUSY;
=C2=A0 }
--=C2=A0
1.8.3.1
--000000000000ebed07057a865efd--