Add Non-Null Check to common driver library to prevent a kernel crash due to an unitialized PCI BAR
Problem: [describe the problem you try to solve with this PR.]
If an address of 0x00 is passed to common::physmap, the entire kernel locks up. No "HALT" is printed, so I suspect there is a null dereference in the physmap call.
0x00 can be passed to physmap implicitly if a PCI BAR isn't initialized. I discovered that when trying to set up an LPSS UART that was connected over PCI. It had a BAR value of 0x00. I'm not sure why (That's the next thing to check), but because it's technically valid for an uninitialized endpoint to have a BAR with a value of zero, we should handle this.
Solution:
- have physmap handle the case where base_address is 0 and return an error.
Changes introduced by this pull request:
- Added a check to drivers/common/physmap that returns an error if 0x00 is passed as the base address ptr.
- Because map_bar calls map_err on the result, the calling driver will now crash, rather than the entire kernel.
Drawbacks:
- I'm not sure if it's ever valid to map address 0x00.
Edited by Timothy Finnegan