Skip to content

Commit

Permalink
pci: Fix end of address space check
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Sebastien Boeuf authored and rbradford committed Jul 25, 2019
1 parent 1971c94 commit 927861c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pci/src/configuration.rs
Expand Up @@ -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 => {
Expand Down

0 comments on commit 927861c

Please sign in to comment.