public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] pci: fix overflow in __pci_hose_bus_to_phys w/ large RAM
@ 2014-08-11 22:09 Stephen Warren
  2014-08-14  9:44 ` Anatolij Gustschin
  0 siblings, 1 reply; 2+ messages in thread
From: Stephen Warren @ 2014-08-11 22:09 UTC (permalink / raw)
  To: u-boot

From: Stephen Warren <swarren@nvidia.com>

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>
---
 drivers/pci/pci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index ed113bf4022f..4fd9c532b3fb 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;
 		}
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [U-Boot] [PATCH] pci: fix overflow in __pci_hose_bus_to_phys w/ large RAM
  2014-08-11 22:09 [U-Boot] [PATCH] pci: fix overflow in __pci_hose_bus_to_phys w/ large RAM Stephen Warren
@ 2014-08-14  9:44 ` Anatolij Gustschin
  0 siblings, 0 replies; 2+ messages in thread
From: Anatolij Gustschin @ 2014-08-14  9:44 UTC (permalink / raw)
  To: u-boot

On Mon, 11 Aug 2014 16:09:28 -0600
Stephen Warren <swarren@wwwdotorg.org> wrote:

> From: Stephen Warren <swarren@nvidia.com>
> 
> 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>
> ---
>  drivers/pci/pci.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

applied to u-boot-staging/agust at denx.de. thanks!

Anatolij

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-08-14  9:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-11 22:09 [U-Boot] [PATCH] pci: fix overflow in __pci_hose_bus_to_phys w/ large RAM Stephen Warren
2014-08-14  9:44 ` Anatolij Gustschin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox