diff options
-rw-r--r-- | mm/mmap.c | 23 |
1 files changed, 10 insertions, 13 deletions
@@ -1068,7 +1068,6 @@ int vma_wants_writenotify(struct vm_area_struct *vma) | |||
1068 | mapping_cap_account_dirty(vma->vm_file->f_mapping); | 1068 | mapping_cap_account_dirty(vma->vm_file->f_mapping); |
1069 | } | 1069 | } |
1070 | 1070 | ||
1071 | |||
1072 | unsigned long mmap_region(struct file *file, unsigned long addr, | 1071 | unsigned long mmap_region(struct file *file, unsigned long addr, |
1073 | unsigned long len, unsigned long flags, | 1072 | unsigned long len, unsigned long flags, |
1074 | unsigned int vm_flags, unsigned long pgoff, | 1073 | unsigned int vm_flags, unsigned long pgoff, |
@@ -1181,22 +1180,20 @@ munmap_back: | |||
1181 | if (vma_wants_writenotify(vma)) | 1180 | if (vma_wants_writenotify(vma)) |
1182 | vma->vm_page_prot = vm_get_page_prot(vm_flags & ~VM_SHARED); | 1181 | vma->vm_page_prot = vm_get_page_prot(vm_flags & ~VM_SHARED); |
1183 | 1182 | ||
1184 | if (!file || !vma_merge(mm, prev, addr, vma->vm_end, | 1183 | if (file && vma_merge(mm, prev, addr, vma->vm_end, |
1185 | vma->vm_flags, NULL, file, pgoff, vma_policy(vma))) { | 1184 | vma->vm_flags, NULL, file, pgoff, vma_policy(vma))) { |
1186 | file = vma->vm_file; | ||
1187 | vma_link(mm, vma, prev, rb_link, rb_parent); | ||
1188 | if (correct_wcount) | ||
1189 | atomic_inc(&inode->i_writecount); | ||
1190 | } else { | ||
1191 | if (file) { | ||
1192 | if (correct_wcount) | ||
1193 | atomic_inc(&inode->i_writecount); | ||
1194 | fput(file); | ||
1195 | } | ||
1196 | mpol_free(vma_policy(vma)); | 1185 | mpol_free(vma_policy(vma)); |
1197 | kmem_cache_free(vm_area_cachep, vma); | 1186 | kmem_cache_free(vm_area_cachep, vma); |
1187 | fput(file); | ||
1188 | } else { | ||
1189 | vma_link(mm, vma, prev, rb_link, rb_parent); | ||
1190 | file = vma->vm_file; | ||
1198 | } | 1191 | } |
1199 | out: | 1192 | |
1193 | /* Once vma denies write, undo our temporary denial count */ | ||
1194 | if (correct_wcount) | ||
1195 | atomic_inc(&inode->i_writecount); | ||
1196 | out: | ||
1200 | mm->total_vm += len >> PAGE_SHIFT; | 1197 | mm->total_vm += len >> PAGE_SHIFT; |
1201 | vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT); | 1198 | vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT); |
1202 | if (vm_flags & VM_LOCKED) { | 1199 | if (vm_flags & VM_LOCKED) { |