]> git.neil.brown.name Git - history.git/commitdiff
ia64: Fix efi_mem_type() and efi_mem_attributes() to avoid potential
authorDavid Mosberger <davidm@tiger.hpl.hp.com>
Tue, 21 Oct 2003 10:52:58 +0000 (03:52 -0700)
committerDavid Mosberger <davidm@tiger.hpl.hp.com>
Tue, 21 Oct 2003 10:52:58 +0000 (03:52 -0700)
underflows.  In my case, the underflows occurred with the
first memory descriptor which got trimmed down to a size of 0.
Due to the underflow, this descriptor ended up covering the entire
address-range which in turn caused Bad Things to happen with the
X server.

arch/ia64/kernel/efi.c

index d29f7f672a0d83c8dfaee8f67f0dac3505a9e062..f9d37a739fe5ccd50d4fd14d70a48f6ad6f3e678 100644 (file)
@@ -685,8 +685,7 @@ efi_mem_type (unsigned long phys_addr)
        for (p = efi_map_start; p < efi_map_end; p += efi_desc_size) {
                md = p;
 
-               if ((md->phys_addr <= phys_addr) && (phys_addr <=
-                   (md->phys_addr + (md->num_pages << EFI_PAGE_SHIFT) - 1)))
+               if (phys_addr - md->phys_addr < (md->num_pages << EFI_PAGE_SHIFT))
                         return md->type;
        }
        return 0;
@@ -706,8 +705,7 @@ efi_mem_attributes (unsigned long phys_addr)
        for (p = efi_map_start; p < efi_map_end; p += efi_desc_size) {
                md = p;
 
-               if ((md->phys_addr <= phys_addr) && (phys_addr <=
-                   (md->phys_addr + (md->num_pages << EFI_PAGE_SHIFT) - 1)))
+               if (phys_addr - md->phys_addr < (md->num_pages << EFI_PAGE_SHIFT))
                        return md->attribute;
        }
        return 0;