Commit 0e1cadb0 authored by Roy Franz's avatar Roy Franz Committed by Matt Fleming

efi: Allow efi_free() to be called with size of 0

Make efi_free() safely callable with size of 0, similar to free() being
callable with NULL pointers, and do nothing in that case.
Remove size checks that this makes redundant.  This also avoids some
size checks in the ARM EFI stub code that will be added as well.
Signed-off-by: default avatarRoy Franz <roy.franz@linaro.org>
Signed-off-by: default avatarMatt Fleming <matt.fleming@intel.com>
parent ae8e9060
...@@ -506,8 +506,7 @@ struct boot_params *make_boot_params(void *handle, efi_system_table_t *_table) ...@@ -506,8 +506,7 @@ struct boot_params *make_boot_params(void *handle, efi_system_table_t *_table)
return boot_params; return boot_params;
fail2: fail2:
if (options_size) efi_free(sys_table, options_size, hdr->cmd_line_ptr);
efi_free(sys_table, options_size, hdr->cmd_line_ptr);
fail: fail:
efi_free(sys_table, 0x4000, (unsigned long)boot_params); efi_free(sys_table, 0x4000, (unsigned long)boot_params);
return NULL; return NULL;
......
...@@ -255,6 +255,9 @@ static void efi_free(efi_system_table_t *sys_table_arg, unsigned long size, ...@@ -255,6 +255,9 @@ static void efi_free(efi_system_table_t *sys_table_arg, unsigned long size,
{ {
unsigned long nr_pages; unsigned long nr_pages;
if (!size)
return;
nr_pages = round_up(size, EFI_PAGE_SIZE) / EFI_PAGE_SIZE; nr_pages = round_up(size, EFI_PAGE_SIZE) / EFI_PAGE_SIZE;
efi_call_phys2(sys_table_arg->boottime->free_pages, addr, nr_pages); efi_call_phys2(sys_table_arg->boottime->free_pages, addr, nr_pages);
} }
......
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