Added an assertion to map_bar that causes the calling driver to panic rather than crash the kernel
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user