summaryrefslogtreecommitdiff
path: root/src/boot/efi/util.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2019-02-08 16:23:40 +0100
committerLennart Poettering <lennart@poettering.net>2019-03-01 12:41:32 +0100
commitb9e452423c25888e147e8aaa25ad8087176eb3a0 (patch)
tree073b0336eef5b498d84ad5bfa6eace3a35490281 /src/boot/efi/util.c
parent5d87589732411c05c90ffab292f31e536502bebb (diff)
downloadsystemd-b9e452423c25888e147e8aaa25ad8087176eb3a0.tar.gz
efi: beef up efivar_get_xyz() to accept NULL return values
Diffstat (limited to 'src/boot/efi/util.c')
-rw-r--r--src/boot/efi/util.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/boot/efi/util.c b/src/boot/efi/util.c
index f1f1674c59..bc1d4ae5c4 100644
--- a/src/boot/efi/util.c
+++ b/src/boot/efi/util.c
@@ -117,6 +117,9 @@ EFI_STATUS efivar_get(const CHAR16 *name, CHAR16 **value) {
if ((size % 2) != 0)
return EFI_INVALID_PARAMETER;
+ if (!value)
+ return EFI_SUCCESS;
+
/* Return buffer directly if it happens to be NUL terminated already */
if (size >= 2 && buf[size-2] == 0 && buf[size-1] == 0) {
*value = (CHAR16*) buf;
@@ -141,7 +144,7 @@ EFI_STATUS efivar_get_int(const CHAR16 *name, UINTN *i) {
EFI_STATUS err;
err = efivar_get(name, &val);
- if (!EFI_ERROR(err))
+ if (!EFI_ERROR(err) && i)
*i = Atoi(val);
return err;
@@ -159,8 +162,10 @@ EFI_STATUS efivar_get_raw(const EFI_GUID *vendor, const CHAR16 *name, CHAR8 **bu
err = uefi_call_wrapper(RT->GetVariable, 5, (CHAR16*) name, (EFI_GUID *)vendor, NULL, &l, buf);
if (!EFI_ERROR(err)) {
- *buffer = buf;
- buf = NULL;
+
+ if (buffer)
+ *buffer = TAKE_PTR(buf);
+
if (size)
*size = l;
}