From 0b84592f458b4e8567aa7d803aff382c1d3b64fd Mon Sep 17 00:00:00 2001 From: Haggai Eran Date: Thu, 13 Sep 2012 10:58:58 +1000 Subject: [PATCH] mm: Fix compiler warning in copy_page_range This patch fixes the warning about mmun_start/end used uninitialized in copy_page_range, by initializing them regardless of whether the notifiers are actually called. It also makes sure the vm_flags in copy_page_range are only read once. Signed-off-by: Haggai Eran Reviewed-by: Minchan Kim Signed-off-by: Andrew Morton --- mm/memory.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index ef003fecea9d..7412354e2272 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -712,7 +712,7 @@ static void print_bad_pte(struct vm_area_struct *vma, unsigned long addr, add_taint(TAINT_BAD_PAGE); } -static inline int is_cow_mapping(vm_flags_t flags) +static inline bool is_cow_mapping(vm_flags_t flags) { return (flags & (VM_SHARED | VM_MAYWRITE)) == VM_MAYWRITE; } @@ -1041,6 +1041,7 @@ int copy_page_range(struct mm_struct *dst_mm, struct mm_struct *src_mm, unsigned long end = vma->vm_end; unsigned long mmun_start; /* For mmu_notifiers */ unsigned long mmun_end; /* For mmu_notifiers */ + bool is_cow; int ret; /* @@ -1074,12 +1075,12 @@ int copy_page_range(struct mm_struct *dst_mm, struct mm_struct *src_mm, * parent mm. And a permission downgrade will only happen if * is_cow_mapping() returns true. */ - if (is_cow_mapping(vma->vm_flags)) { - mmun_start = addr; - mmun_end = end; + is_cow = is_cow_mapping(vma->vm_flags); + mmun_start = addr; + mmun_end = end; + if (is_cow) mmu_notifier_invalidate_range_start(src_mm, mmun_start, mmun_end); - } ret = 0; dst_pgd = pgd_offset(dst_mm, addr); @@ -1095,7 +1096,7 @@ int copy_page_range(struct mm_struct *dst_mm, struct mm_struct *src_mm, } } while (dst_pgd++, src_pgd++, addr = next, addr != end); - if (is_cow_mapping(vma->vm_flags)) + if (is_cow) mmu_notifier_invalidate_range_end(src_mm, mmun_start, mmun_end); return ret; } -- 2.39.5