Skip to content

Commit 8bc3c3f

Browse files
Naoya Horiguchitorvalds
authored andcommitted
mm: drop NULL return check of pte_offset_map_lock()
pte_offset_map_lock() finds and takes ptl, and returns pte. But some callers return without unlocking the ptl when pte == NULL, which seems weird. Git history said that !pte check in change_pte_range() was introduced in commit 1ad9f62 ("mm: numa: recheck for transhuge pages under lock during protection changes") and still remains after commit 175ad4f ("mm: mprotect: use pmd_trans_unstable instead of taking the pmd_lock") which partially reverts 1ad9f62. So I think that it's just dead code. Many other caller of pte_offset_map_lock() never check NULL return, so let's do likewise. Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Naoya Horiguchi <[email protected]> Acked-by: Vlastimil Babka <[email protected]> Cc: Mel Gorman <[email protected]> Cc: Johannes Weiner <[email protected]> Cc: Andrea Arcangeli <[email protected]> Cc: Rik van Riel <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent d73d3c9 commit 8bc3c3f

File tree

2 files changed

+0
-4
lines changed

2 files changed

+0
-4
lines changed

mm/memory.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4014,8 +4014,6 @@ static int __follow_pte_pmd(struct mm_struct *mm, unsigned long address,
40144014
goto out;
40154015

40164016
ptep = pte_offset_map_lock(mm, pmd, address, ptlp);
4017-
if (!ptep)
4018-
goto out;
40194017
if (!pte_present(*ptep))
40204018
goto unlock;
40214019
*ptepp = ptep;

mm/mprotect.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,6 @@ static unsigned long change_pte_range(struct vm_area_struct *vma, pmd_t *pmd,
5858
* reading.
5959
*/
6060
pte = pte_offset_map_lock(vma->vm_mm, pmd, addr, &ptl);
61-
if (!pte)
62-
return 0;
6361

6462
/* Get target node for single threaded private VMAs */
6563
if (prot_numa && !(vma->vm_flags & VM_SHARED) &&

0 commit comments

Comments
 (0)