[PATCH] 2.2.18pre2: fencepost error in __ioremap() [AGP]

From: Chip Salzenberg (chip@valinux.com)
Date: Sat Sep 02 2000 - 00:31:02 EST


The AGP patches add some code to __ioremap. That code seems to me to
have a fencepost error.

In the below hunk, note that temp_end is set to "temp_addr+(size-1)".
It points _at_ the last page to be examined, not beyond it. So the
loop should be controlled by a "<=" test, not a "<" test. Without
this patch, the last page in the range is not tested for reservation.

Index: arch/i386/mm/ioremap.c
--- arch/i386/mm/ioremap.c.prev
+++ arch/i386/mm/ioremap.c Fri Sep 1 20:11:25 2000
@@ -118,5 +118,5 @@ void * __ioremap(unsigned long phys_addr
                 temp_end = temp_addr + (size - 1);
               
- for(i = MAP_NR(temp_addr); i < MAP_NR(temp_end); i++) {
+ for(i = MAP_NR(temp_addr); i <= MAP_NR(temp_end); i++) {
                         if(!PageReserved(mem_map + i))
                                 return NULL;

-- 
Chip Salzenberg              - a.k.a. -              <chip@valinux.com>
"I wanted to play hopscotch with the impenetrable mystery of existence,
    but he stepped in a wormhole and had to go in early."  // MST3K
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Thu Sep 07 2000 - 21:00:12 EST