aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorIlias Apalodimas <ilias.apalodimas@linaro.org>2021-03-27 10:56:07 +0200
committerHeinrich Schuchardt <xypron.glpk@gmx.de>2021-04-10 12:00:24 +0200
commitf4dc1bc9f0ad0ee1d23aa185a4e8d9e904e6d88e (patch)
tree4b72f6700c0f20c007e71ebf2c1e0858833c80f1 /lib
parentcd64031c16d29856cb13275d89b0742f857cb3ff (diff)
downloadu-boot-f4dc1bc9f0ad0ee1d23aa185a4e8d9e904e6d88e.zip
u-boot-f4dc1bc9f0ad0ee1d23aa185a4e8d9e904e6d88e.tar.gz
u-boot-f4dc1bc9f0ad0ee1d23aa185a4e8d9e904e6d88e.tar.bz2
efi_loader: Cleanup get_var duplication
get_var() is defined statically in efi_bootmgr.c and doesn't properly check a buffer allocation. Remove it completely and use the exported function from efi_var_common.c that does the same thing Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Diffstat (limited to 'lib')
-rw-r--r--lib/efi_loader/efi_bootmgr.c36
1 files changed, 2 insertions, 34 deletions
diff --git a/lib/efi_loader/efi_bootmgr.c b/lib/efi_loader/efi_bootmgr.c
index 46c8011..1fe1923 100644
--- a/lib/efi_loader/efi_bootmgr.c
+++ b/lib/efi_loader/efi_bootmgr.c
@@ -31,38 +31,6 @@ static const struct efi_runtime_services *rs;
*/
/**
- * get_var() - get UEFI variable
- *
- * It is the caller's duty to free the returned buffer.
- *
- * @name: name of variable
- * @vendor: vendor GUID of variable
- * @size: size of allocated buffer
- * Return: buffer with variable data or NULL
- */
-static void *get_var(u16 *name, const efi_guid_t *vendor,
- efi_uintn_t *size)
-{
- efi_status_t ret;
- void *buf = NULL;
-
- *size = 0;
- ret = efi_get_variable_int(name, vendor, NULL, size, buf, NULL);
- if (ret == EFI_BUFFER_TOO_SMALL) {
- buf = malloc(*size);
- ret = efi_get_variable_int(name, vendor, NULL, size, buf, NULL);
- }
-
- if (ret != EFI_SUCCESS) {
- free(buf);
- *size = 0;
- return NULL;
- }
-
- return buf;
-}
-
-/**
* try_load_entry() - try to load image for boot option
*
* Attempt to load load-option number 'n', returning device_path and file_path
@@ -89,7 +57,7 @@ static efi_status_t try_load_entry(u16 n, efi_handle_t *handle,
varname[6] = hexmap[(n & 0x00f0) >> 4];
varname[7] = hexmap[(n & 0x000f) >> 0];
- load_option = get_var(varname, &efi_global_variable_guid, &size);
+ load_option = efi_get_var(varname, &efi_global_variable_guid, &size);
if (!load_option)
return EFI_LOAD_ERROR;
@@ -210,7 +178,7 @@ efi_status_t efi_bootmgr_load(efi_handle_t *handle, void **load_options)
}
/* BootOrder */
- bootorder = get_var(L"BootOrder", &efi_global_variable_guid, &size);
+ bootorder = efi_get_var(L"BootOrder", &efi_global_variable_guid, &size);
if (!bootorder) {
log_info("BootOrder not defined\n");
ret = EFI_NOT_FOUND;