Commit d2d79af1 authored by David Mosberger's avatar David Mosberger

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.
parent fa872b34
......@@ -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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment