Skip to content

Commit 37d4bb2

Browse files
committed
Prevent getting a raw reference from PhysicalMapping if T: !Unpin
1 parent 35f9fba commit 37d4bb2

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

acpi/src/handler.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use core::{fmt, ops::Deref, ptr::NonNull};
1+
use core::{fmt, ops::Deref, pin::Pin, ptr::NonNull};
22

33
/// Describes a physical mapping created by `AcpiHandler::map_physical_region` and unmapped by
44
/// `AcpiHandler::unmap_physical_region`. The region mapped must be at least `size_of::<T>()`
@@ -65,6 +65,10 @@ where
6565
self.virtual_start
6666
}
6767

68+
pub fn get(&self) -> Pin<&T> {
69+
unsafe { Pin::new_unchecked(self.virtual_start.as_ref()) }
70+
}
71+
6872
pub fn region_length(&self) -> usize {
6973
self.region_length
7074
}
@@ -82,6 +86,7 @@ unsafe impl<H: AcpiHandler + Send, T: Send> Send for PhysicalMapping<H, T> {}
8286

8387
impl<H, T> Deref for PhysicalMapping<H, T>
8488
where
89+
T: Unpin,
8590
H: AcpiHandler,
8691
{
8792
type Target = T;

acpi/src/platform/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ where
124124

125125
let madt = tables.find_table::<Madt>();
126126
let (interrupt_model, processor_info) = match madt {
127-
Ok(madt) => madt.parse_interrupt_model_in(allocator)?,
127+
Ok(madt) => madt.get().parse_interrupt_model_in(allocator)?,
128128
Err(_) => (InterruptModel::Unknown, None),
129129
};
130130
let pm_timer = PmTimer::new(&fadt)?;

acpi/src/sdt.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ impl SdtHeader {
197197

198198
// This is usually redundant compared to simply calling `validate_checksum` but respects custom
199199
// `AcpiTable::validate` implementations.
200-
table_mapping.validate()?;
200+
table_mapping.get().validate()?;
201201

202202
Ok(table_mapping)
203203
}

0 commit comments

Comments
 (0)