From 6c9c8a037c529b109881dc96dfbd1a0e130efa20 Mon Sep 17 00:00:00 2001 From: Pawel Dziepak Date: Wed, 22 May 2013 14:18:50 +0200 Subject: [PATCH] vm: fix area insertion logic * When looking for a place for new area the size of the area to be inserted instead of the next area size was used to check whether we are already past the upper bound. * There was an attempt to insert area even if we were past the upper bound. --- src/system/kernel/vm/VMUserAddressSpace.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/system/kernel/vm/VMUserAddressSpace.cpp b/src/system/kernel/vm/VMUserAddressSpace.cpp index ac989f51db..dd10892829 100644 --- a/src/system/kernel/vm/VMUserAddressSpace.cpp +++ b/src/system/kernel/vm/VMUserAddressSpace.cpp @@ -588,7 +588,7 @@ second_chance: } // keep walking - while (next != NULL && next->Base() + size - 1 <= end) { + while (next != NULL && next->Base() + next->Size() - 1 <= end) { addr_t alignedBase = ROUNDUP(last->Base() + last->Size(), alignment); addr_t nextBase = min_c(end, next->Base() - 1); @@ -615,8 +615,8 @@ second_chance: addr_t alignedBase = ROUNDUP(last->Base() + last->Size(), alignment); - if (is_valid_spot(last->Base() + (last->Size() - 1), alignedBase, - size, end)) { + if (next == NULL && is_valid_spot(last->Base() + (last->Size() - 1), + alignedBase, size, end)) { if (is_randomized(addressSpec)) { alignedBase = _RandomizeAddress(alignedBase, end - size + 1,