Skip to content

Commit 5227fc0

Browse files
uefi: Use global system table in MemoryMapBackingMemory::drop
1 parent 416a1db commit 5227fc0

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

uefi/src/mem/memory_map/impl_.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
//! as well as relevant helper types, such as [`MemoryMapBackingMemory`].
33
44
use super::*;
5+
use crate::boot;
56
use crate::table::system_table_boot;
67
use core::fmt::{Debug, Display, Formatter};
78
use core::ops::{Index, IndexMut};
@@ -341,8 +342,8 @@ impl MemoryMapBackingMemory {
341342
// Don't drop when we use this in unit tests.
342343
impl Drop for MemoryMapBackingMemory {
343344
fn drop(&mut self) {
344-
if let Some(bs) = system_table_boot() {
345-
let res = unsafe { bs.boot_services().free_pool(self.0.as_ptr().cast()) };
345+
if boot::are_boot_services_active() {
346+
let res = unsafe { boot::free_pool(self.0.cast()) };
346347
if let Err(e) = res {
347348
log::error!("Failed to deallocate memory map: {e:?}");
348349
}

0 commit comments

Comments
 (0)