mm/migrate: initialize pud_entry in migrate_vma()
diff mbox series

Message ID 20190719233225.12243-1-rcampbell@nvidia.com
State In Next
Commit 782564a676ac270f8b02ea0be28dea357267494f
Headers show
Series
  • mm/migrate: initialize pud_entry in migrate_vma()
Related show

Commit Message

Ralph Campbell July 19, 2019, 11:32 p.m. UTC
When CONFIG_MIGRATE_VMA_HELPER is enabled, migrate_vma() calls
migrate_vma_collect() which initializes a struct mm_walk but
didn't initialize mm_walk.pud_entry. (Found by code inspection)
Use a C structure initialization to make sure it is set to NULL.

Fixes: 8763cb45ab967 ("mm/migrate: new memory migration helper for use with
device memory")
Cc: stable@vger.kernel.org
Signed-off-by: Ralph Campbell <rcampbell@nvidia.com>
Cc: "Jérôme Glisse" <jglisse@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
---
 mm/migrate.c | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

Comments

John Hubbard July 20, 2019, 2:03 a.m. UTC | #1
On 7/19/19 4:32 PM, Ralph Campbell wrote:
> When CONFIG_MIGRATE_VMA_HELPER is enabled, migrate_vma() calls
> migrate_vma_collect() which initializes a struct mm_walk but
> didn't initialize mm_walk.pud_entry. (Found by code inspection)
> Use a C structure initialization to make sure it is set to NULL.
> 
> Fixes: 8763cb45ab967 ("mm/migrate: new memory migration helper for use with
> device memory")
> Cc: stable@vger.kernel.org
> Signed-off-by: Ralph Campbell <rcampbell@nvidia.com>
> Cc: "Jérôme Glisse" <jglisse@redhat.com>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> ---
>  mm/migrate.c | 17 +++++++----------
>  1 file changed, 7 insertions(+), 10 deletions(-)
> 
> diff --git a/mm/migrate.c b/mm/migrate.c
> index 515718392b24..a42858d8e00b 100644
> --- a/mm/migrate.c
> +++ b/mm/migrate.c
> @@ -2340,16 +2340,13 @@ static int migrate_vma_collect_pmd(pmd_t *pmdp,
>  static void migrate_vma_collect(struct migrate_vma *migrate)
>  {
>  	struct mmu_notifier_range range;
> -	struct mm_walk mm_walk;
> -
> -	mm_walk.pmd_entry = migrate_vma_collect_pmd;
> -	mm_walk.pte_entry = NULL;
> -	mm_walk.pte_hole = migrate_vma_collect_hole;
> -	mm_walk.hugetlb_entry = NULL;
> -	mm_walk.test_walk = NULL;
> -	mm_walk.vma = migrate->vma;
> -	mm_walk.mm = migrate->vma->vm_mm;
> -	mm_walk.private = migrate;
> +	struct mm_walk mm_walk = {
> +		.pmd_entry = migrate_vma_collect_pmd,
> +		.pte_hole = migrate_vma_collect_hole,
> +		.vma = migrate->vma,
> +		.mm = migrate->vma->vm_mm,
> +		.private = migrate,
> +	};

Neatly done.

>  
>  	mmu_notifier_range_init(&range, MMU_NOTIFY_CLEAR, 0, NULL, mm_walk.mm,
>  				migrate->start,
> 

Reviewed-by: John Hubbard <jhubbard@nvidia.com>

thanks,

Patch
diff mbox series

diff --git a/mm/migrate.c b/mm/migrate.c
index 515718392b24..a42858d8e00b 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -2340,16 +2340,13 @@  static int migrate_vma_collect_pmd(pmd_t *pmdp,
 static void migrate_vma_collect(struct migrate_vma *migrate)
 {
 	struct mmu_notifier_range range;
-	struct mm_walk mm_walk;
-
-	mm_walk.pmd_entry = migrate_vma_collect_pmd;
-	mm_walk.pte_entry = NULL;
-	mm_walk.pte_hole = migrate_vma_collect_hole;
-	mm_walk.hugetlb_entry = NULL;
-	mm_walk.test_walk = NULL;
-	mm_walk.vma = migrate->vma;
-	mm_walk.mm = migrate->vma->vm_mm;
-	mm_walk.private = migrate;
+	struct mm_walk mm_walk = {
+		.pmd_entry = migrate_vma_collect_pmd,
+		.pte_hole = migrate_vma_collect_hole,
+		.vma = migrate->vma,
+		.mm = migrate->vma->vm_mm,
+		.private = migrate,
+	};
 
 	mmu_notifier_range_init(&range, MMU_NOTIFY_CLEAR, 0, NULL, mm_walk.mm,
 				migrate->start,