diff mbox series

[15/16] mm/memory_failure: fix the missing pte_unmap() call

Message ID 20210924224403.3ZN1b5z2V%akpm@linux-foundation.org (mailing list archive)
State New
Headers show
Series [01/16] mm, hwpoison: add is_free_buddy_page() in HWPoisonHandlable() | expand

Commit Message

Andrew Morton Sept. 24, 2021, 10:44 p.m. UTC
From: Qi Zheng <zhengqi.arch@bytedance.com>
Subject: mm/memory_failure: fix the missing pte_unmap() call

The paired pte_unmap() call is missing before the
dev_pagemap_mapping_shift() returns.  So fix it.

Davidsaid "I guess this code never runs on 32bit / highmem, that's why we
didn't notice so far".

[akpm@linux-foundation.org: cleanup]
Link: https://lkml.kernel.org/r/20210923122642.4999-1-zhengqi.arch@bytedance.com
Signed-off-by: Qi Zheng <zhengqi.arch@bytedance.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
Cc: Naoya Horiguchi <naoya.horiguchi@nec.com>
Cc: Muchun Song <songmuchun@bytedance.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 mm/memory-failure.c |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
diff mbox series

Patch

--- a/mm/memory-failure.c~mm-memory_failure-fix-the-missing-pte_unmap-call
+++ a/mm/memory-failure.c
@@ -306,6 +306,7 @@  static unsigned long dev_pagemap_mapping
 		struct vm_area_struct *vma)
 {
 	unsigned long address = vma_address(page, vma);
+	unsigned long ret = 0;
 	pgd_t *pgd;
 	p4d_t *p4d;
 	pud_t *pud;
@@ -329,11 +330,10 @@  static unsigned long dev_pagemap_mapping
 	if (pmd_devmap(*pmd))
 		return PMD_SHIFT;
 	pte = pte_offset_map(pmd, address);
-	if (!pte_present(*pte))
-		return 0;
-	if (pte_devmap(*pte))
-		return PAGE_SHIFT;
-	return 0;
+	if (pte_present(*pte) && pte_devmap(*pte))
+		ret = PAGE_SHIFT;
+	pte_unmap(pte);
+	return ret;
 }
 
 /*