From d2d79af1c4b892971e0706b9caef86005c2b4866 Mon Sep 17 00:00:00 2001 From: David Mosberger Date: Tue, 21 Oct 2003 03:52:58 -0700 Subject: [PATCH] ia64: Fix efi_mem_type() and efi_mem_attributes() to avoid potential 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 | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/arch/ia64/kernel/efi.c b/arch/ia64/kernel/efi.c index d29f7f672a0d8..f9d37a739fe5c 100644 --- a/arch/ia64/kernel/efi.c +++ b/arch/ia64/kernel/efi.c @@ -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; -- 2.53.0