aboutsummaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
Diffstat (limited to 'mm')
-rw-r--r--mm/mremap.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/mm/mremap.c b/mm/mremap.c
index 3708655378e9..457d34ef3bf2 100644
--- a/mm/mremap.c
+++ b/mm/mremap.c
@@ -456,13 +456,14 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
456 unsigned long charged = 0; 456 unsigned long charged = 0;
457 bool locked = false; 457 bool locked = false;
458 458
459 down_write(&current->mm->mmap_sem);
460
461 if (flags & ~(MREMAP_FIXED | MREMAP_MAYMOVE)) 459 if (flags & ~(MREMAP_FIXED | MREMAP_MAYMOVE))
462 goto out; 460 return ret;
461
462 if (flags & MREMAP_FIXED && !(flags & MREMAP_MAYMOVE))
463 return ret;
463 464
464 if (addr & ~PAGE_MASK) 465 if (addr & ~PAGE_MASK)
465 goto out; 466 return ret;
466 467
467 old_len = PAGE_ALIGN(old_len); 468 old_len = PAGE_ALIGN(old_len);
468 new_len = PAGE_ALIGN(new_len); 469 new_len = PAGE_ALIGN(new_len);
@@ -473,12 +474,13 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
473 * a zero new-len is nonsensical. 474 * a zero new-len is nonsensical.
474 */ 475 */
475 if (!new_len) 476 if (!new_len)
476 goto out; 477 return ret;
478
479 down_write(&current->mm->mmap_sem);
477 480
478 if (flags & MREMAP_FIXED) { 481 if (flags & MREMAP_FIXED) {
479 if (flags & MREMAP_MAYMOVE) 482 ret = mremap_to(addr, old_len, new_addr, new_len,
480 ret = mremap_to(addr, old_len, new_addr, new_len, 483 &locked);
481 &locked);
482 goto out; 484 goto out;
483 } 485 }
484 486