Bug in __ioremap() + Patch

David Howells (david.howells@nexor.co.uk)
Wed, 21 Jan 1998 09:08:40 GMT


I've found a bug in __ioremap(), and have attached a patch to fix it. The bug
occurs if the bit of memory you're interested in lies right at the end of the
memory range, and so fulfils the following condition:

phys-addr + size = 0
(0xffffd000) (0x3000)

The patch is:

+++ linux-2.1.78c/arch/i386/mm/ioremap.c Tue Jan 20 20:41:53 1998
--- orig/linux-2.1.78/arch/i386/mm/ioremap.c Fri Apr 4 16:52:17 1997
@@ -95,7 +95,7 @@
if (phys_addr & ~PAGE_MASK)
return NULL;
size = PAGE_ALIGN(size);
- if (!size || size > phys_addr + size)
+ if (!size || (size != ~phys_addr+1 && size > phys_addr + size))
return NULL;
area = get_vm_area(size);
if (!area)

I'm sure there's better ways of writing the extra bit in the condition, but it
works.

All the best,
David Howells