Skip to content

Commit 8d63e4c

Browse files
Ralph Campbelltorvalds
authored andcommitted
mm/hmm: fix uninitialized use of 'entry' in hmm_vma_walk_pmd()
The variable 'entry' is used before being initialized in hmm_vma_walk_pmd(). No bad effect (beside performance hit) so !non_swap_entry(0) evaluate to true which trigger a fault as if CPU was trying to access migrated memory and migrate memory back from device memory to regular memory. This function (hmm_vma_walk_pmd()) is called when a device driver tries to populate its own page table. For migrated memory it should not happen as the device driver should already have populated its page table correctly during the migration. Only case I can think of is multi-GPU where a second GPU triggers migration back to regular memory. Again this would just result in a performance hit, nothing bad would happen. Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Ralph Campbell <[email protected]> Signed-off-by: Jérôme Glisse <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent def9b71 commit 8d63e4c

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

mm/hmm.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -418,16 +418,14 @@ static int hmm_vma_walk_pmd(pmd_t *pmdp,
418418
}
419419

420420
if (!pte_present(pte)) {
421-
swp_entry_t entry;
421+
swp_entry_t entry = pte_to_swp_entry(pte);
422422

423423
if (!non_swap_entry(entry)) {
424424
if (hmm_vma_walk->fault)
425425
goto fault;
426426
continue;
427427
}
428428

429-
entry = pte_to_swp_entry(pte);
430-
431429
/*
432430
* This is a special swap entry, ignore migration, use
433431
* device and report anything else as error.

0 commit comments

Comments
 (0)