--- linux-openmosix-orig/linux-openmosix/mm/mremap.c Thu Feb 5 10:51:31 2004 +++ linux-openmosix-mod/linux-openmosix/mm/mremap.c Wed Jun 9 18:15:10 2004 @@ -80,12 +80,16 @@ static int move_one_page(struct mm_struct *mm, unsigned long old_addr, unsigned long new_addr) { int error = 0; - pte_t * src; + pte_t * src, * dst; spin_lock(&mm->page_table_lock); src = get_one_pte(mm, old_addr); - if (src) - error = copy_one_pte(mm, src, alloc_one_pte(mm, new_addr)); + if (src) { + dst = alloc_one_pte(mm, new_addr); + src = get_one_pte(mm, old_addr); + if (src) + error = copy_one_pte(mm, src, dst); + } spin_unlock(&mm->page_table_lock); return error; } @@ -265,16 +269,20 @@ if ((addr <= new_addr) && (addr+old_len) > new_addr) goto out; - do_munmap(current->mm, new_addr, new_len); + ret = do_munmap(current->mm, new_addr, new_len); + if (ret && new_len) + goto out; } /* * Always allow a shrinking remap: that just unmaps * the unnecessary pages.. */ - ret = addr; if (old_len >= new_len) { - do_munmap(current->mm, addr+new_len, old_len - new_len); + ret = do_munmap(current->mm, addr+new_len, old_len - new_len); + if (ret && old_len != new_len) + goto out; + ret = addr; if (!(flags & MREMAP_FIXED) || (new_addr == addr)) goto out; }