Commit 5c91c0e7 authored by Qi Zheng's avatar Qi Zheng Committed by Linus Torvalds

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.

David says:
 "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.comSigned-off-by: default avatarQi Zheng <zhengqi.arch@bytedance.com>
Reviewed-by: default avatarDavid Hildenbrand <david@redhat.com>
Cc: Naoya Horiguchi <naoya.horiguchi@nec.com>
Cc: Muchun Song <songmuchun@bytedance.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 19532869
...@@ -306,6 +306,7 @@ static unsigned long dev_pagemap_mapping_shift(struct page *page, ...@@ -306,6 +306,7 @@ static unsigned long dev_pagemap_mapping_shift(struct page *page,
struct vm_area_struct *vma) struct vm_area_struct *vma)
{ {
unsigned long address = vma_address(page, vma); unsigned long address = vma_address(page, vma);
unsigned long ret = 0;
pgd_t *pgd; pgd_t *pgd;
p4d_t *p4d; p4d_t *p4d;
pud_t *pud; pud_t *pud;
...@@ -329,11 +330,10 @@ static unsigned long dev_pagemap_mapping_shift(struct page *page, ...@@ -329,11 +330,10 @@ static unsigned long dev_pagemap_mapping_shift(struct page *page,
if (pmd_devmap(*pmd)) if (pmd_devmap(*pmd))
return PMD_SHIFT; return PMD_SHIFT;
pte = pte_offset_map(pmd, address); pte = pte_offset_map(pmd, address);
if (!pte_present(*pte)) if (pte_present(*pte) && pte_devmap(*pte))
return 0; ret = PAGE_SHIFT;
if (pte_devmap(*pte)) pte_unmap(pte);
return PAGE_SHIFT; return ret;
return 0;
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment