Fix possible UB in rmm::init.

I tested compiling the kernel with a more recent rustc, and this
triggered UB. Don't know for sure why there was an invalid entry passed
to the kernel, but it did.
This commit is contained in:
4lDO2
2024-09-07 23:12:50 +02:00
parent 0c99e1bd0a
commit 4626c74b78
3 changed files with 6 additions and 6 deletions
+2 -2
View File
@@ -29,7 +29,7 @@ pub enum BootloaderMemoryKind {
pub struct BootloaderMemoryEntry {
pub base: u64,
pub size: u64,
pub kind: BootloaderMemoryKind,
pub kind: u64,
}
unsafe fn page_flags<A: Arch>(virt: VirtualAddress) -> PageFlags<RmmA> {
@@ -347,7 +347,7 @@ pub unsafe fn init(
// Copy memory map from bootloader location, and page align it
let mut area_i = 0;
for bootloader_area in bootloader_areas.iter() {
if { bootloader_area.kind } != BootloaderMemoryKind::Free {
if { bootloader_area.kind } != BootloaderMemoryKind::Free as u64 {
// Not a free area
continue;
}
+2 -2
View File
@@ -29,7 +29,7 @@ pub enum BootloaderMemoryKind {
pub struct BootloaderMemoryEntry {
pub base: u64,
pub size: u64,
pub kind: BootloaderMemoryKind,
pub kind: u64,
}
unsafe fn page_flags<A: Arch>(virt: VirtualAddress) -> PageFlags<A> {
@@ -327,7 +327,7 @@ pub unsafe fn init(
// Copy memory map from bootloader location, and page align it
let mut area_i = 0;
for bootloader_area in bootloader_areas.iter() {
if { bootloader_area.kind } != BootloaderMemoryKind::Free {
if { bootloader_area.kind } != BootloaderMemoryKind::Free as u64 {
// Not a free area
continue;
}
+2 -2
View File
@@ -28,7 +28,7 @@ pub enum BootloaderMemoryKind {
pub struct BootloaderMemoryEntry {
pub base: u64,
pub size: u64,
pub kind: BootloaderMemoryKind,
pub kind: u64,
}
unsafe fn page_flags<A: Arch>(virt: VirtualAddress) -> PageFlags<A> {
@@ -321,7 +321,7 @@ pub unsafe fn init(
let areas_raw = &mut *AREAS.get();
for bootloader_area in bootloader_areas.iter() {
if { bootloader_area.kind } != BootloaderMemoryKind::Free {
if { bootloader_area.kind } != BootloaderMemoryKind::Free as u64 {
// Not a free area
continue;
}