]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
efi_loader: Don't delete variable from memory if adding a new one failed
authorIlias Apalodimas <apalos@gmail.com>
Wed, 3 Apr 2024 15:43:53 +0000 (18:43 +0300)
committerHeinrich Schuchardt <heinrich.schuchardt@canonical.com>
Mon, 8 Apr 2024 11:03:37 +0000 (13:03 +0200)
Our efi_var_mem_xxx() functions don't have a replace variant. Instead we
add a new variable and delete the old instance when trying to replace a
variable. Currently we delete the old version without checking the new
one got added

Signed-off-by: Ilias Apalodimas <apalos@gmail.com>
Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
lib/efi_loader/efi_variable.c

index 6fe3792a12a5382db59bae589f3611f4bedacafc..2951dc78c7dcb1798c224658261d8b19c7ed8a9c 100644 (file)
@@ -360,11 +360,12 @@ efi_status_t efi_set_variable_int(const u16 *variable_name,
                ret = efi_var_mem_ins(variable_name, vendor, attributes,
                                      data_size, data, 0, NULL, time);
        }
-       efi_var_mem_del(var);
 
        if (ret != EFI_SUCCESS)
                return ret;
 
+       efi_var_mem_del(var);
+
        if (var_type == EFI_AUTH_VAR_PK)
                ret = efi_init_secure_state();
        else