mm/migrate_device: do not access pgmap for non zone device pages
Subsystems (2)
PATCH v2 1/1 mm/migrate_device: do not access pgmap for non zone device pages
page_pgmap() is referenced before checking if the page is a zone device page and this triggers the warning in page_pgmap(). Refactor the code to use the helper function after relevant checks.
Signed-off-by Balbir Singh <[email protected]>
Cc Alistair Popple <[email protected]>
Cc Jason Gunthorpe <[email protected]>
Cc David Hildenbrand <[email protected]>
Cc Dan Williams <[email protected]>
Reviewed-by Alistair Popple <[email protected]>
---
This patch replaces 11ba213916b9 and fixes 7f1cfd71153b ("mm: allow compound zone device pages") on mm-unstable
Changelog v2:
- Added {} around the if statement as per coding style
- Added Reviewed-by/Acked-by tags
mm/migrate_device.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
mm/migrate_device.c +9 -6
@@ -153,14 +153,17 @@ static int migrate_vma_collect_pmd(pmd_t *pmdp, goto next; } page =vm_normal_page (migrate->vma, addr, pte); - pgmap =page_pgmap (page);if (page && !is_zone_device_page (page) && - !(migrate->flags &MIGRATE_VMA_SELECT_SYSTEM )) - goto next; -else if (page &&is_device_coherent_page (page) && - (!(migrate->flags &MIGRATE_VMA_SELECT_DEVICE_COHERENT ) || - pgmap->owner != migrate->pgmap_owner)) + !(migrate->flags &MIGRATE_VMA_SELECT_SYSTEM )) { goto next; + }else if (page &&is_device_coherent_page (page)) { + pgmap =page_pgmap (page); + +if (!(migrate->flags & +MIGRATE_VMA_SELECT_DEVICE_COHERENT ) || + pgmap->owner != migrate->pgmap_owner) + goto next; + } mpfn =migrate_pfn (pfn) |MIGRATE_PFN_MIGRATE ; mpfn |=pte_write (pte) ?MIGRATE_PFN_WRITE :0 ; }
Signature · 1 line
2.48.1