Do not allow phys_to_virt overflow
This commit is contained in:
+4
-1
@@ -97,7 +97,10 @@ pub trait Arch: Clone + Copy {
|
||||
|
||||
#[inline(always)]
|
||||
unsafe fn phys_to_virt(phys: PhysicalAddress) -> VirtualAddress {
|
||||
VirtualAddress::new(phys.data() + Self::PHYS_OFFSET)
|
||||
match phys.data().checked_add(Self::PHYS_OFFSET) {
|
||||
Some(some) => VirtualAddress::new(some),
|
||||
None => panic!("phys_to_virt({:#x}) overflow", phys.data()),
|
||||
}
|
||||
}
|
||||
|
||||
fn virt_is_valid(address: VirtualAddress) -> bool;
|
||||
|
||||
Reference in New Issue
Block a user