diff options
Diffstat (limited to 'mm/madvise.c')
-rw-r--r-- | mm/madvise.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/mm/madvise.c b/mm/madvise.c index 60542d006ec1..93ee375b38e7 100644 --- a/mm/madvise.c +++ b/mm/madvise.c | |||
@@ -287,9 +287,11 @@ asmlinkage long sys_madvise(unsigned long start, size_t len_in, int behavior) | |||
287 | struct vm_area_struct * vma, *prev; | 287 | struct vm_area_struct * vma, *prev; |
288 | int unmapped_error = 0; | 288 | int unmapped_error = 0; |
289 | int error = -EINVAL; | 289 | int error = -EINVAL; |
290 | int write; | ||
290 | size_t len; | 291 | size_t len; |
291 | 292 | ||
292 | if (madvise_need_mmap_write(behavior)) | 293 | write = madvise_need_mmap_write(behavior); |
294 | if (write) | ||
293 | down_write(¤t->mm->mmap_sem); | 295 | down_write(¤t->mm->mmap_sem); |
294 | else | 296 | else |
295 | down_read(¤t->mm->mmap_sem); | 297 | down_read(¤t->mm->mmap_sem); |
@@ -354,7 +356,7 @@ asmlinkage long sys_madvise(unsigned long start, size_t len_in, int behavior) | |||
354 | vma = find_vma(current->mm, start); | 356 | vma = find_vma(current->mm, start); |
355 | } | 357 | } |
356 | out: | 358 | out: |
357 | if (madvise_need_mmap_write(behavior)) | 359 | if (write) |
358 | up_write(¤t->mm->mmap_sem); | 360 | up_write(¤t->mm->mmap_sem); |
359 | else | 361 | else |
360 | up_read(¤t->mm->mmap_sem); | 362 | up_read(¤t->mm->mmap_sem); |