From 927861ced2325e82ca492f6f242869e54372da40 Mon Sep 17 00:00:00 2001 From: Sebastien Boeuf Date: Wed, 24 Jul 2019 14:15:49 -0700 Subject: [PATCH] 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 --- pci/src/configuration.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pci/src/configuration.rs b/pci/src/configuration.rs index 618e42a6d..eb96c6e2e 100755 --- a/pci/src/configuration.rs +++ b/pci/src/configuration.rs @@ -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 => {