diff --git a/loader-proto.c b/loader-proto.c index 85014efce..3f6dfd50b 100644 --- a/loader-proto.c +++ b/loader-proto.c @@ -186,8 +186,6 @@ try_load_from_lf2(EFI_DEVICE_PATH *dp, buffer_properties_t *bprop) static void free_pages_alloc_image(SHIM_LOADED_IMAGE *image) { - char *buffer; - if (!image || !image->alloc_address || !image->alloc_pages) return; @@ -196,9 +194,8 @@ free_pages_alloc_image(SHIM_LOADED_IMAGE *image) * are set on a loaded image, this will cause a page fault when it * is freed. Ensure W+ X- are set instead before freeing. */ - buffer = (void *)ALIGN_VALUE((unsigned long)image->alloc_address, image->alloc_alignment); - update_mem_attrs((uintptr_t)buffer, image->alloc_pages * PAGE_SIZE, MEM_ATTR_R|MEM_ATTR_W, - MEM_ATTR_X); + update_mem_attrs((uintptr_t)image->alloc_address, + image->alloc_pages * PAGE_SIZE, MEM_ATTR_R|MEM_ATTR_W, MEM_ATTR_X); BS->FreePages(image->alloc_address, image->alloc_pages); image->alloc_address = 0; diff --git a/pe.c b/pe.c index 22ad0fe48..d5ad49946 100644 --- a/pe.c +++ b/pe.c @@ -717,7 +717,7 @@ handle_image (void *data, unsigned int datasize, dprint(L"Loading 0x%llx bytes at 0x%llx\n", (unsigned long long)context.ImageSize, (unsigned long long)(uintptr_t)buffer); - update_mem_attrs((uintptr_t)buffer, alloc_size, MEM_ATTR_R|MEM_ATTR_W, + update_mem_attrs((uintptr_t)buffer, context.ImageSize, MEM_ATTR_R|MEM_ATTR_W, MEM_ATTR_X); CopyMem(buffer, data, context.SizeOfHeaders);