From: Michal Simek Date: Thu, 19 Mar 2026 07:15:07 +0000 (+0100) Subject: efi_loader: efi_var_sf: Do not fail on blank SPI Flash X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=57eae396ec91729d5655c26456f8ac3bac439202;p=thirdparty%2Fu-boot.git efi_loader: efi_var_sf: Do not fail on blank SPI Flash When SPI Flash is blank (first boot or erased), efi_var_from_storage() returns EFI_DEVICE_ERROR because efi_var_restore() fails on invalid magic/CRC. This prevents the EFI subsystem from initializing. Check the magic value before attempting to restore variables. If the magic does not match EFI_VAR_FILE_MAGIC, treat it as an empty store and return EFI_SUCCESS, matching the behavior of the file-based efi_var_file.c which deliberately returns EFI_SUCCESS on missing or corrupted variable files to avoid blocking the boot process. Similarly, if the magic matches but efi_var_restore() fails (e.g. corrupted CRC), log the error but still return EFI_SUCCESS. Suggested-by: John Toomey Signed-off-by: Michal Simek Reviewed-by: Ilias Apalodimas Reviewed-by: Heinrich Schuchardt --- diff --git a/lib/efi_loader/efi_var_sf.c b/lib/efi_loader/efi_var_sf.c index 6eae8d46464..b84ec8e67dc 100644 --- a/lib/efi_loader/efi_var_sf.c +++ b/lib/efi_loader/efi_var_sf.c @@ -98,11 +98,8 @@ efi_status_t efi_var_from_storage(void) goto error; } - if (efi_var_restore(buf, false) != EFI_SUCCESS) { + if (efi_var_restore(buf, false) != EFI_SUCCESS) log_err("No valid EFI variables in SPI Flash\n"); - ret = EFI_DEVICE_ERROR; - goto error; - } ret = EFI_SUCCESS; error: