From d6b7b0b1eb8825047c58b9380a40dd65b6093785 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Tue, 24 Nov 2009 07:43:18 -0500 Subject: [PATCH] --- yaml --- r: 174845 b: refs/heads/master c: 1a0ef85f84feb13f07b604fcf5b90ef7c2b5c82f h: refs/heads/master i: 174843: 88f786b591a87c4bf2392906289538c7305065f2 v: v3 --- [refs] | 2 +- trunk/mm/mremap.c | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/[refs] b/[refs] index 508307392c9e..c419565ca1c3 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: ecc1a8993751de4e82eb18640d631dae1f626bd6 +refs/heads/master: 1a0ef85f84feb13f07b604fcf5b90ef7c2b5c82f diff --git a/trunk/mm/mremap.c b/trunk/mm/mremap.c index 5f346178f16f..90e422c9f410 100644 --- a/trunk/mm/mremap.c +++ b/trunk/mm/mremap.c @@ -366,6 +366,17 @@ static unsigned long mremap_to(unsigned long addr, return ret; } +static int vma_expandable(struct vm_area_struct *vma, unsigned long delta) +{ + unsigned long max_addr = TASK_SIZE; + if (vma->vm_next) + max_addr = vma->vm_next->vm_start; + if (max_addr - vma->vm_end < delta) + return 0; + /* we need to do arch-specific checks here */ + return 1; +} + /* * Expand (or shrink) an existing mapping, potentially moving it at the * same time (controlled by the MREMAP_MAYMOVE flag and available VM space) @@ -430,11 +441,8 @@ unsigned long do_mremap(unsigned long addr, /* old_len exactly to the end of the area.. */ if (old_len == vma->vm_end - addr) { - unsigned long max_addr = TASK_SIZE; - if (vma->vm_next) - max_addr = vma->vm_next->vm_start; /* can we just expand the current mapping? */ - if (max_addr - addr >= new_len) { + if (vma_expandable(vma, new_len - old_len)) { int pages = (new_len - old_len) >> PAGE_SHIFT; vma_adjust(vma, vma->vm_start,