diff --git a/kernel/heap/src/lib.rs b/kernel/heap/src/lib.rs index d5e9700d1c..9d93a8336a 100644 --- a/kernel/heap/src/lib.rs +++ b/kernel/heap/src/lib.rs @@ -89,7 +89,7 @@ unsafe impl GlobalAlloc for Heap { } unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) { - if (ptr as usize) < INITIAL_HEAP_END_ADDR { + if KERNEL_HEAP_START <= (ptr as usize) && (ptr as usize) < INITIAL_HEAP_END_ADDR { self.initial_allocator.lock().deallocate(ptr, layout); } else {