linux-mips
[Top] [All Lists]

[PATCH] Alchemy: fix off by two error in __fixup_bigphys_addr()

To: ralf@linux-mips.org
Subject: [PATCH] Alchemy: fix off by two error in __fixup_bigphys_addr()
From: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Date: Mon, 10 Dec 2007 20:36:50 +0300
Cc: linux-mips@linux-mips.org
Organization: MontaVista Software Inc.
Original-recipient: rfc822;linux-mips@linux-mips.org
Sender: linux-mips-bounce@linux-mips.org
User-agent: KMail/1.5
he PCI specific code in this function doesn't check for the address range being
under the upper bound of the PCI memory window correctly -- fix this, somewhat
beautifying the code around the check, while at it...

Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>

---
 arch/mips/au1000/common/setup.c |    9 ++++-----
 1 files changed, 4 insertions(+), 5 deletions(-)

Index: linux-2.6/arch/mips/au1000/common/setup.c
===================================================================
--- linux-2.6.orig/arch/mips/au1000/common/setup.c
+++ linux-2.6/arch/mips/au1000/common/setup.c
@@ -137,12 +137,11 @@ phys_t __fixup_bigphys_addr(phys_t phys_
 
 #ifdef CONFIG_PCI
        {
-               u32 start, end;
+               u32 start = (u32)Au1500_PCI_MEM_START;
+               u32 end   = (u32)Au1500_PCI_MEM_END;
 
-               start = (u32)Au1500_PCI_MEM_START;
-               end = (u32)Au1500_PCI_MEM_END;
-               /* check for pci memory window */
-               if ((phys_addr >= start) && ((phys_addr + size) < end))
+               /* Check for PCI memory window */
+               if (phys_addr >= start && (phys_addr + size - 1) <= end)
                        return (phys_t)
                               ((phys_addr - start) + Au1500_PCI_MEM_START);
        }


<Prev in Thread] Current Thread [Next in Thread>