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:
@@ -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,
|
||||||
|
|||||||
@@ -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++) {
|
||||||
|
|||||||
@@ -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++) {
|
||||||
|
|||||||
@@ -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++) {
|
||||||
|
|||||||
@@ -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++) {
|
||||||
|
|||||||
Reference in New Issue
Block a user