diff --git a/src/kernel/memory.rs b/src/kernel/memory.rs index 1dbac6b..3ee5fce 100644 --- a/src/kernel/memory.rs +++ b/src/kernel/memory.rs @@ -27,15 +27,22 @@ lazy_static! { pub fn deallocate_usable() -> Result<(), AllocError> { init_statics(); + let mut any_error: Option = None; let mut bytes_deallocated: u64 = 0; for entry in MEMMAP_RESPONSE.entries() { if (entry.entry_type == EntryType::USABLE) | (entry.entry_type == EntryType::BOOTLOADER_RECLAIMABLE) { - deallocate(**entry)?; + if let Err(error) = deallocate(**entry) { + any_error = Some(error); + } bytes_deallocated += entry.length; } } log_trace!("Deallocated 0x{:x} bytes", bytes_deallocated); - Ok(()) + if let Some(error) = any_error { + Err(error) + } else { + Ok(()) + } } @@ -129,6 +136,7 @@ pub fn log_address() { ); } +// Have to initialize all of these before reclaiming bootloader memory fn init_statics() { let _ = EXECUTABLE_FILE_RESPONSE; let _ = HHDM_RESPONSE;