patch-2.3.23 linux/arch/i386/mm/ioremap.c
Next file: linux/arch/i386/vmlinux.lds
Previous file: linux/arch/i386/mm/init.c
Back to the patch index
Back to the overall index
- Lines: 63
- Date:
Tue Oct 19 10:22:20 1999
- Orig file:
v2.3.22/linux/arch/i386/mm/ioremap.c
- Orig date:
Sun Jul 25 13:45:25 1999
diff -u --recursive --new-file v2.3.22/linux/arch/i386/mm/ioremap.c linux/arch/i386/mm/ioremap.c
@@ -20,15 +20,19 @@
end = address + size;
if (end > PMD_SIZE)
end = PMD_SIZE;
+ if (address >= end)
+ BUG();
do {
- if (!pte_none(*pte))
+ if (!pte_none(*pte)) {
printk("remap_area_pte: page already exists\n");
+ BUG();
+ }
set_pte(pte, mk_pte_phys(phys_addr, __pgprot(_PAGE_PRESENT | _PAGE_RW |
_PAGE_DIRTY | _PAGE_ACCESSED | flags)));
address += PAGE_SIZE;
phys_addr += PAGE_SIZE;
pte++;
- } while (address < end);
+ } while (address && (address < end));
}
static inline int remap_area_pmd(pmd_t * pmd, unsigned long address, unsigned long size,
@@ -41,6 +45,8 @@
if (end > PGDIR_SIZE)
end = PGDIR_SIZE;
phys_addr -= address;
+ if (address >= end)
+ BUG();
do {
pte_t * pte = pte_alloc_kernel(pmd, address);
if (!pte)
@@ -48,7 +54,7 @@
remap_area_pte(pte, address, end - address, address + phys_addr, flags);
address = (address + PMD_SIZE) & PMD_MASK;
pmd++;
- } while (address < end);
+ } while (address && (address < end));
return 0;
}
@@ -61,8 +67,11 @@
phys_addr -= address;
dir = pgd_offset(&init_mm, address);
flush_cache_all();
- while (address < end) {
- pmd_t *pmd = pmd_alloc_kernel(dir, address);
+ if (address >= end)
+ BUG();
+ do {
+ pmd_t *pmd;
+ pmd = pmd_alloc_kernel(dir, address);
if (!pmd)
return -ENOMEM;
if (remap_area_pmd(pmd, address, end - address,
@@ -71,7 +80,7 @@
set_pgdir(address, *dir);
address = (address + PGDIR_SIZE) & PGDIR_MASK;
dir++;
- }
+ } while (address && (address < end));
flush_tlb_all();
return 0;
}
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)