Added an assertion to map_bar that causes the calling driver to panic rather than crash the kernel

This commit is contained in:
Timothy Finnegan
2024-09-20 18:42:03 -07:00
parent 306bb7d698
commit 806e8b42b7
2 changed files with 6 additions and 2 deletions
+6
View File
@@ -126,6 +126,12 @@ pub unsafe fn physmap(
ty: MemoryType,
) -> Result<*mut ()> {
// TODO: arraystring?
//Return an error rather than potentially crash the kernel.
if(base_phys == 0) {
return Err(Error::new(EINVAL));
}
let path = format!(
"/scheme/memory/physical@{}",
match ty {
-2
View File
@@ -374,8 +374,6 @@ impl PciFunctionHandle {
} else {
let (bar, bar_size) = self.config.func.bars[bir as usize].expect_mem();
assert!(bar > 0); //Panic, rather than potentially crash the kernel if the bar isnt initialized.
let ptr = unsafe {
common::physmap(
bar,