Skip to content

Commit 8fa3248

Browse files
committed
Prevent getting a raw reference from PhysicalMapping if T: !Unpin
1 parent 97cf8d8 commit 8fa3248

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

Diff for: acpi/src/handler.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
use core::{
2-
fmt,
3-
ops::{Deref, DerefMut},
4-
ptr::NonNull,
5-
};
1+
use core::{fmt, ops::Deref, pin::Pin, ptr::NonNull};
62

73
/// Describes a physical mapping created by `AcpiHandler::map_physical_region` and unmapped by
84
/// `AcpiHandler::unmap_physical_region`. The region mapped must be at least `size_of::<T>()`
@@ -73,6 +69,10 @@ where
7369
self.virtual_start
7470
}
7571

72+
pub fn get(&self) -> Pin<&T> {
73+
unsafe { Pin::new_unchecked(self.virtual_start.as_ref()) }
74+
}
75+
7676
pub fn region_length(&self) -> usize {
7777
self.region_length
7878
}
@@ -90,6 +90,7 @@ unsafe impl<H: AcpiHandler + Send, T: Send> Send for PhysicalMapping<H, T> {}
9090

9191
impl<H, T> Deref for PhysicalMapping<H, T>
9292
where
93+
T: Unpin,
9394
H: AcpiHandler,
9495
{
9596
type Target = T;

Diff for: 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)?;

Diff for: 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)