Skip to content
Snippets Groups Projects
Commit b4bd6554 authored by Marcel Ziswiler's avatar Marcel Ziswiler Committed by Tom Rini
Browse files

pci: fix address range check in __pci_hose_phys_to_bus()


The address range check may overflow if the memory region is located at
the top of the 32-bit address space. This can e.g. be seen on TK1 if
using the E1000 gigabit Ethernet driver where start and size are both
0x80000000 leading to the following messages:

Apalis TK1 # tftpboot $loadaddr test_file
Using e1000#0 device
TFTP from server 192.168.10.1; our IP address is 192.168.10.2
Filename 'test_file'.
Load address: 0x80408000
Loading: pci_hose_phys_to_bus: invalid physical address

This patch fixes this by changing the order of the addition vs.
subtraction in the range check just like already done in
__pci_hose_bus_to_phys().

Reported-by: default avatarIvan Mercier <ivan.mercier@nexvision.fr>
Signed-off-by: default avatarMarcel Ziswiler <marcel.ziswiler@toradex.com>
Reviewed-by: default avatarBin Meng <bmeng.cn@gmail.com>
Reviewed-by: default avatarStephen Warren <swarren@nvidia.com>
Acked-by: default avatarSimon Glass <sjg@chromium.org>
parent cfdaf4ca
No related branches found
No related tags found
No related merge requests found
...@@ -268,7 +268,7 @@ int __pci_hose_phys_to_bus(struct pci_controller *hose, ...@@ -268,7 +268,7 @@ int __pci_hose_phys_to_bus(struct pci_controller *hose,
bus_addr = phys_addr - res->phys_start + res->bus_start; bus_addr = phys_addr - res->phys_start + res->bus_start;
if (bus_addr >= res->bus_start && if (bus_addr >= res->bus_start &&
bus_addr < res->bus_start + res->size) { (bus_addr - res->bus_start) < res->size) {
*ba = bus_addr; *ba = bus_addr;
return 0; return 0;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment