pci: Fix end of address space check

The check performed on the end address was wrong since the end address
was actually the address right after the end. To get the right end
address, we need to add (region size - 1) to the start address.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
Sebastien Boeuf 2019-07-24 14:15:49 -07:00 committed by Rob Bradford
parent 1971c94e4e
commit 927861ced2

View File

@ -457,7 +457,7 @@ impl PciConfiguration {
let bar_idx = BAR0_REG + config.reg_idx;
let end_addr = config
.addr
.checked_add(config.size)
.checked_add(config.size - 1)
.ok_or_else(|| Error::BarAddressInvalid(config.addr, config.size))?;
match config.region_type {
PciBarRegionType::Memory32BitRegion | PciBarRegionType::IORegion => {