efi: Allow efi_free() to be called with size of 0
authorRoy Franz <roy.franz@linaro.org>
Sun, 22 Sep 2013 22:45:38 +0000 (15:45 -0700)
committerMark Brown <broonie@linaro.org>
Mon, 16 Jun 2014 20:18:00 +0000 (21:18 +0100)
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: Roy Franz <roy.franz@linaro.org>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
(cherry picked from commit 0e1cadb05bba2293b4575c8cab275313d181d94f)
Signed-off-by: Mark Brown <broonie@linaro.org>
arch/x86/boot/compressed/eboot.c
drivers/firmware/efi/efi-stub-helper.c

index 43e5a2f90d3058acd253eaa0fd6329531bd08b67..9671b49182f505c64437a30a1645b9dab559d063 100644 (file)
@@ -946,8 +946,7 @@ struct boot_params *make_boot_params(void *handle, efi_system_table_t *_table)
 
        return boot_params;
 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:
        efi_free(sys_table, 0x4000, (unsigned long)boot_params);
        return NULL;
index b314bf720272226088722796ebae0cf66dae708e..fda510fa357941f3c83b418ff0e45d93fdf70e9e 100644 (file)
@@ -255,6 +255,9 @@ static void efi_free(efi_system_table_t *sys_table_arg, unsigned long size,
 {
        unsigned long nr_pages;
 
+       if (!size)
+               return;
+
        nr_pages = round_up(size, EFI_PAGE_SIZE) / EFI_PAGE_SIZE;
        efi_call_phys2(sys_table_arg->boottime->free_pages, addr, nr_pages);
 }