diff options
author | Ard Biesheuvel <ardb@kernel.org> | 2023-10-02 09:50:05 +0000 |
---|---|---|
committer | Ard Biesheuvel <ardb@kernel.org> | 2023-10-02 09:50:05 +0000 |
commit | 5d203b0143aaba9ea55f1efb623df02f8ae5ca52 (patch) | |
tree | 4451246cd5e03e65a2f96004636234c31897448b | |
parent | fc968782576a4067b9120d7ccd47f52be5d713e6 (diff) | |
download | efilite-5d203b0143aaba9ea55f1efb623df02f8ae5ca52.tar.gz |
Fix cfgtable locking and dealloc size
-rw-r--r-- | src/efi/configtable.rs | 3 | ||||
-rw-r--r-- | src/efi/mod.rs | 4 | ||||
-rw-r--r-- | src/efi/systemtable.rs | 2 |
3 files changed, 6 insertions, 3 deletions
diff --git a/src/efi/configtable.rs b/src/efi/configtable.rs index 121334a..b382835 100644 --- a/src/efi/configtable.rs +++ b/src/efi/configtable.rs @@ -10,3 +10,6 @@ pub struct ConfigurationTable { pub vendor_guid: Guid, pub vendor_table: *const (), } + +unsafe impl Send for ConfigurationTable {} +unsafe impl Sync for ConfigurationTable {} diff --git a/src/efi/mod.rs b/src/efi/mod.rs index 2c54663..f2aa76f 100644 --- a/src/efi/mod.rs +++ b/src/efi/mod.rs @@ -168,7 +168,7 @@ impl ProtocolPtr { type ProtocolDb = BTreeMap::<(Handle, Guid), ProtocolPtr>; static PROTOCOL_DB: Spinlock<ProtocolDb> = Spinlock::new(BTreeMap::new()); -static mut CONFIGTABLE_DB: BTreeMap::<Guid, ConfigurationTable> = BTreeMap::new(); +static CONFIGTABLE_DB: Spinlock<BTreeMap::<Guid, ConfigurationTable>> = Spinlock::new(BTreeMap::new()); static RTSDATA_ALLOCATOR: LockedHeap = LockedHeap::empty(); @@ -207,7 +207,7 @@ pub fn install_configtable( guid: &Guid, table: *const () ) { - let db = unsafe { &mut CONFIGTABLE_DB }; + let mut db = CONFIGTABLE_DB.lock(); let entry = ConfigurationTable { vendor_guid: *guid, vendor_table: table, diff --git a/src/efi/systemtable.rs b/src/efi/systemtable.rs index 7c71780..65e7908 100644 --- a/src/efi/systemtable.rs +++ b/src/efi/systemtable.rs @@ -85,7 +85,7 @@ impl SystemTable { let entsize = core::mem::size_of::<ConfigurationTable>(); if st.number_of_table_entries != 0 { // drop the old array first - let size = st.number_of_table_entries * new.len(); + let size = entsize * st.number_of_table_entries; let layout = core::alloc::Layout::from_size_align(size, 8).unwrap(); unsafe { alloc.deallocate(NonNull::new_unchecked(st.configuration_table as *mut u8), layout); |