summaryrefslogtreecommitdiff
path: root/drivers/pci/pci.c
diff options
context:
space:
mode:
authorStephen Warren <swarren@nvidia.com>2014-08-11 16:09:28 -0600
committerAnatolij Gustschin <agust@denx.de>2014-08-14 11:38:47 +0200
commitd878c9a932eae626aced58128357fc6155f88739 (patch)
treead1b5e6967b3a7d9b141d3fd89104f66ddb53839 /drivers/pci/pci.c
parent686dca0fc4eb077b089c7507f899097d001c8ce3 (diff)
downloadu-boot-imx-d878c9a932eae626aced58128357fc6155f88739.zip
u-boot-imx-d878c9a932eae626aced58128357fc6155f88739.tar.gz
u-boot-imx-d878c9a932eae626aced58128357fc6155f88739.tar.bz2
pci: fix overflow in __pci_hose_bus_to_phys w/ large RAM
If a 32-bit system has 2GB of RAM, and the base address of that RAM is 2GB, then start+size will overflow a 32-bit value (to a value of 0). To avoid such an overflow, convert __pci_hose_bus_to_phys() to calculate the offset of a bus address into a PCI region, rather than comparing a bus address against the end of a PCI region. Signed-off-by: Stephen Warren <swarren@nvidia.com>
Diffstat (limited to 'drivers/pci/pci.c')
-rw-r--r--drivers/pci/pci.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index ed113bf..4fd9c53 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -323,7 +323,7 @@ int __pci_hose_bus_to_phys(struct pci_controller *hose,
continue;
if (bus_addr >= res->bus_start &&
- bus_addr < res->bus_start + res->size) {
+ (bus_addr - res->bus_start) < res->size) {
*pa = (bus_addr - res->bus_start + res->phys_start);
return 0;
}