diff options
author | Ilias Apalodimas <ilias.apalodimas@linaro.org> | 2022-12-29 10:13:22 +0200 |
---|---|---|
committer | Heinrich Schuchardt <heinrich.schuchardt@canonical.com> | 2022-12-29 10:51:50 +0100 |
commit | 77bb14758dcb1876c7bbfa4cead67c90f2d86a44 (patch) | |
tree | a8a225ba1fefb8bc0184d07537ceefe608f7817c /lib/efi_loader/efi_var_file.c | |
parent | fcf583b4a7f74de1475a953bd934efcdd4e34309 (diff) |
efi_loader: avoid adding variables twice
When the efi subsystem starts we restore variables that are both in a
file or stored into the .efi_runtime section of U-Boot. However once
a variable gets created or changed the preseeded entries will end up in
the file. As a consequence on the next boot we will end up adding
identical variable entries twice.
Fix this by checking if the to be inserted variable already exists.
Also swap the restoration order and start with the file instead of the
builtin variables, so a user can replace the preseeded ones if needed.
Tested-by: Leo Yan <leo.yan@linaro.org>
Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Diffstat (limited to 'lib/efi_loader/efi_var_file.c')
-rw-r--r-- | lib/efi_loader/efi_var_file.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/efi_loader/efi_var_file.c b/lib/efi_loader/efi_var_file.c index de9ba8de99..62e071bd83 100644 --- a/lib/efi_loader/efi_var_file.c +++ b/lib/efi_loader/efi_var_file.c @@ -187,6 +187,8 @@ efi_status_t efi_var_restore(struct efi_var_file *buf, bool safe) continue; if (!var->length) continue; + if (efi_var_mem_find(&var->guid, var->name, NULL)) + continue; ret = efi_var_mem_ins(var->name, &var->guid, var->attr, var->length, data, 0, NULL, var->time); |