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:
@@ -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 {
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user