Skip to content

Commit

Permalink
mm/hmm: fix uninitialized use of 'entry' in hmm_vma_walk_pmd()
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
Ralph Campbell authored and torvalds committed Feb 1, 2018
1 parent def9b71 commit 8d63e4c
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions mm/hmm.c
Original file line number Diff line number Diff line change
Expand Up @@ -418,16 +418,14 @@ static int hmm_vma_walk_pmd(pmd_t *pmdp,
}

if (!pte_present(pte)) {
swp_entry_t entry;
swp_entry_t entry = pte_to_swp_entry(pte);

if (!non_swap_entry(entry)) {
if (hmm_vma_walk->fault)
goto fault;
continue;
}

entry = pte_to_swp_entry(pte);

/*
* This is a special swap entry, ignore migration, use
* device and report anything else as error.
Expand Down

0 comments on commit 8d63e4c

Please sign in to comment.