Merge branch 'add_assertion_to_pci_driver' into 'master'

Add Non-Null Check to common driver library to prevent a kernel crash due to an unitialized PCI BAR

See merge request redox-os/drivers!200
This commit is contained in:
Jeremy Soller
2024-09-21 02:25:38 +00:00
2 changed files with 7 additions and 0 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 {
+1
View File
@@ -373,6 +373,7 @@ impl PciFunctionHandle {
Ok(mapped_bar)
} else {
let (bar, bar_size) = self.config.func.bars[bir as usize].expect_mem();
let ptr = unsafe {
common::physmap(
bar,