mirror of
https://git.proxmox.com/git/fwupd
synced 2025-05-29 18:43:18 +00:00
uefi: Do not pass required attrs to fwup_delete_variable()
This lets us refactor some code and remove some complexity.
This commit is contained in:
parent
aa6498866c
commit
00b87884c4
@ -35,7 +35,7 @@ fwupd_debug_efivar_append(CHAR16 *out1)
|
||||
static BOOLEAN once = TRUE;
|
||||
if (once) {
|
||||
once = FALSE;
|
||||
fwup_delete_variable(name, &fwupdate_guid, attrs);
|
||||
fwup_delete_variable(name, &fwupdate_guid);
|
||||
} else {
|
||||
attrs |= EFI_VARIABLE_APPEND_WRITE;
|
||||
}
|
||||
|
@ -13,8 +13,21 @@
|
||||
#include "fwup-efi.h"
|
||||
|
||||
EFI_STATUS
|
||||
fwup_delete_variable(CHAR16 *name, EFI_GUID *guid, UINT32 attrs)
|
||||
fwup_delete_variable(CHAR16 *name, EFI_GUID *guid)
|
||||
{
|
||||
EFI_STATUS rc;
|
||||
UINT32 attrs = 0;
|
||||
|
||||
/* get the attrs so we can delete it */
|
||||
rc = uefi_call_wrapper(RT->GetVariable, 5, name, guid, &attrs, NULL, NULL);
|
||||
if (EFI_ERROR(rc)) {
|
||||
if (rc == EFI_NOT_FOUND) {
|
||||
fwup_debug(L"Not deleting variable '%s' as not found", name);
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
fwup_debug(L"Could not get variable '%s' for delete: %r", name, rc);
|
||||
return rc;
|
||||
}
|
||||
return uefi_call_wrapper(RT->SetVariable, 5, name, guid, attrs, 0, NULL);
|
||||
}
|
||||
|
||||
|
@ -57,8 +57,7 @@ typedef struct {
|
||||
} __attribute__((__packed__)) EFI_LOAD_OPTION;
|
||||
|
||||
EFI_STATUS fwup_delete_variable (CHAR16 *name,
|
||||
EFI_GUID *guid,
|
||||
UINT32 attrs);
|
||||
EFI_GUID *guid);
|
||||
EFI_STATUS fwup_set_variable (CHAR16 *name,
|
||||
EFI_GUID *guid,
|
||||
VOID *data,
|
||||
|
@ -72,14 +72,12 @@ fwup_populate_update_info(CHAR16 *name, FWUP_UPDATE_TABLE *info_out)
|
||||
|
||||
if (info_size < sizeof(*info)) {
|
||||
fwup_warning(L"Update '%s' is is too small", name);
|
||||
fwup_delete_variable(name, &fwupdate_guid, attrs);
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (info_size - sizeof(EFI_DEVICE_PATH) <= sizeof(*info)) {
|
||||
fwup_warning(L"Update '%s' is malformed, "
|
||||
L"and cannot hold a file path", name);
|
||||
fwup_delete_variable(name, &fwupdate_guid, attrs);
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -89,7 +87,6 @@ fwup_populate_update_info(CHAR16 *name, FWUP_UPDATE_TABLE *info_out)
|
||||
fwup_warning(L"Update '%s' has an invalid file path, "
|
||||
L"device path offset is %d, but total size is %d",
|
||||
name, is, info_size);
|
||||
fwup_delete_variable(name, &fwupdate_guid, attrs);
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -99,7 +96,6 @@ fwup_populate_update_info(CHAR16 *name, FWUP_UPDATE_TABLE *info_out)
|
||||
fwup_warning(L"Update '%s' has an invalid file path, "
|
||||
L"update info size: %d dp size: %d size for dp: %d",
|
||||
name, info_size, sz, is);
|
||||
fwup_delete_variable(name, &fwupdate_guid, attrs);
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -165,6 +161,7 @@ fwup_populate_update_table(FWUP_UPDATE_TABLE **updates, UINTN *n_updates_out)
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
rc = fwup_populate_update_info(variable_name, update);
|
||||
if (EFI_ERROR(rc)) {
|
||||
fwup_delete_variable(variable_name, &fwupdate_guid);
|
||||
fwup_warning(L"Could not populate update info for '%s'", variable_name);
|
||||
return rc;
|
||||
}
|
||||
@ -431,12 +428,11 @@ fwup_delete_boot_entry(VOID)
|
||||
continue;
|
||||
|
||||
UINTN info_size = 0;
|
||||
UINT32 attrs = 0;
|
||||
_cleanup_free VOID *info_ptr = NULL;
|
||||
|
||||
/* get the data */
|
||||
rc = fwup_get_variable(variable_name, &vendor_guid,
|
||||
&info_ptr, &info_size, &attrs);
|
||||
&info_ptr, &info_size, NULL);
|
||||
if (EFI_ERROR(rc))
|
||||
return rc;
|
||||
if (info_size < sizeof(EFI_LOAD_OPTION))
|
||||
@ -455,8 +451,7 @@ fwup_delete_boot_entry(VOID)
|
||||
fwup_warning(L"Failed to delete boot entry from BootOrder");
|
||||
return rc;
|
||||
}
|
||||
rc = fwup_delete_variable(variable_name,
|
||||
&vendor_guid, attrs);
|
||||
rc = fwup_delete_variable(variable_name, &vendor_guid);
|
||||
if (EFI_ERROR(rc)) {
|
||||
fwup_warning(L"Failed to delete boot entry");
|
||||
return rc;
|
||||
|
Loading…
Reference in New Issue
Block a user