Re: ioremap() bugs + patch

Eric D. Seppanen (sepp@primenet.com)
Sun, 21 Feb 1999 22:59:38 -0600 (CST)


Last week I posted a patch to fix a samll problem in ioremap(). Thanks to
Petr Vandrovec for pointing out some problems with it. This one should be
better.

Summary: the 2.2.1 ioremap does not allow mapping of the very top of
physical space (right up to 0xFFFFFFFF). This should fix that problem and
moves two lines of code so that requests that extend past the top of
physical space fail in the intended way.

Eric Seppanen / sepp@primenet.com

--- linux-2.2.1/arch/i386/mm/ioremap.c Fri Nov 27 17:03:14 1998
+++ linux/arch/i386/mm/ioremap.c Fri Feb 19 11:23:38 1999
@@ -96,9 +96,16 @@
unsigned long offset;

/*
+ * Don't allow zero size or mappings that wrap.
+ * Be careful of integer overflows!
+ */
+ if (!size || phys_addr > phys_addr+(size-1))
+ return NULL;
+
+ /*
* Don't remap the low PCI/ISA area, it's always mapped..
*/
- if (phys_addr >= 0xA0000 && (phys_addr+size) <= 0x100000)
+ if (phys_addr >= 0xA0000 && (phys_addr+(size-1)) < 0x100000)
return phys_to_virt(phys_addr);

/*
@@ -113,12 +120,6 @@
offset = phys_addr & ~PAGE_MASK;
phys_addr &= PAGE_MASK;
size = PAGE_ALIGN(size + offset);
-
- /*
- * Don't allow mappings that wrap..
- */
- if (!size || size > phys_addr + size)
- return NULL;

/*
* Ok, go for it..

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/