bootloader: Fix an overlooked condition in mmu_allocate()

The size variable at this point is actually a page count.
The test should never be true anyway though. Maybe we should use a
pages variable for clarity?
This commit is contained in:
François Revol
2013-02-21 16:35:37 +01:00
parent 8dc3f98eda
commit 32bd2dedd9
5 changed files with 10 additions and 7 deletions
+2 -2
View File
@@ -474,8 +474,8 @@ mmu_allocate(void *virtualAddress, size_t size)
addr_t address = (addr_t)virtualAddress; addr_t address = (addr_t)virtualAddress;
// is the address within the valid range? // is the address within the valid range?
if (address < KERNEL_BASE if (address < KERNEL_BASE || address + size * B_PAGE_SIZE
|| address + size >= KERNEL_BASE + kMaxKernelSize) { >= KERNEL_BASE + kMaxKernelSize) {
TRACE(("mmu_allocate in illegal range\n address: %" B_PRIx32 TRACE(("mmu_allocate in illegal range\n address: %" B_PRIx32
" KERNELBASE: %" B_PRIx32 " KERNEL_BASE + kMaxKernelSize: %" " KERNELBASE: %" B_PRIx32 " KERNEL_BASE + kMaxKernelSize: %"
B_PRIx32 " address + size : %" B_PRIx32 "\n", (uint32)address, B_PRIx32 " address + size : %" B_PRIx32 "\n", (uint32)address,
+2 -1
View File
@@ -338,7 +338,8 @@ mmu_allocate(void *virtualAddress, size_t size)
addr_t address = (addr_t)virtualAddress; addr_t address = (addr_t)virtualAddress;
// is the address within the valid range? // is the address within the valid range?
if (address < KERNEL_BASE || address + size >= KERNEL_BASE + kMaxKernelSize) if (address < KERNEL_BASE || address + size * B_PAGE_SIZE
>= KERNEL_BASE + kMaxKernelSize)
return NULL; return NULL;
for (uint32 i = 0; i < size; i++) { for (uint32 i = 0; i < size; i++) {
+2 -1
View File
@@ -338,7 +338,8 @@ mmu_allocate(void *virtualAddress, size_t size)
addr_t address = (addr_t)virtualAddress; addr_t address = (addr_t)virtualAddress;
// is the address within the valid range? // is the address within the valid range?
if (address < KERNEL_BASE || address + size >= KERNEL_BASE + kMaxKernelSize) if (address < KERNEL_BASE || address + size * B_PAGE_SIZE
>= KERNEL_BASE + kMaxKernelSize)
return NULL; return NULL;
for (uint32 i = 0; i < size; i++) { for (uint32 i = 0; i < size; i++) {
+2 -1
View File
@@ -339,7 +339,8 @@ mmu_allocate(void *virtualAddress, size_t size)
addr_t address = (addr_t)virtualAddress; addr_t address = (addr_t)virtualAddress;
// is the address within the valid range? // is the address within the valid range?
if (address < KERNEL_BASE || address + size >= KERNEL_BASE + kMaxKernelSize) if (address < KERNEL_BASE || address + size * B_PAGE_SIZE
>= KERNEL_BASE + kMaxKernelSize)
return NULL; return NULL;
for (uint32 i = 0; i < size; i++) { for (uint32 i = 0; i < size; i++) {
+2 -2
View File
@@ -397,8 +397,8 @@ mmu_allocate(void *virtualAddress, size_t size)
addr_t address = (addr_t)virtualAddress; addr_t address = (addr_t)virtualAddress;
// is the address within the valid range? // is the address within the valid range?
if (address < KERNEL_LOAD_BASE if (address < KERNEL_LOAD_BASE || address + size * B_PAGE_SIZE
|| address + size >= KERNEL_LOAD_BASE + kMaxKernelSize) >= KERNEL_LOAD_BASE + kMaxKernelSize)
return NULL; return NULL;
for (uint32 i = 0; i < size; i++) { for (uint32 i = 0; i < size; i++) {