[PATCH v1 1/2] bootmeth: efi_mgr: Do not discard the EFI boot manager error

Aristo Chen via U-Boot <[email protected]>
Newsgroups org.u-boot-project.lists.u-boot
Message-ID <[email protected]>
efi_mgr_boot() assigns the status returned by efi_bootmgr_run() to a
local variable and then returns 0. A zero return from a bootmeth's
boot() method means "should not get here", so bootflow_boot() reports
-EFAULT for every boot manager failure and the real cause (no boot
option loadable, load error, ...) is lost. The unused assignment also
trips -Wunused-but-set-variable on newer compilers.

Map the EFI status to an errno instead: EFI_NOT_FOUND (no BootOrder)
becomes -ENOENT and any other failure -EIO.

Signed-off-by: Aristo Chen <[email protected]>
---
 boot/bootmeth_efi_mgr.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/boot/bootmeth_efi_mgr.c b/boot/bootmeth_efi_mgr.c
index 6e70c36ad99..eb4d9a5b5a6 100644
--- a/boot/bootmeth_efi_mgr.c
+++ b/boot/bootmeth_efi_mgr.c
@@ -84,10 +84,13 @@ static int efi_mgr_read_file(struct udevice *dev, struct bootflow *bflow,
 
 static int efi_mgr_boot(struct udevice *dev, struct bootflow *bflow)
 {
-	int ret;
+	efi_status_t ret;
 
 	/* Booting is handled by the 'bootefi bootmgr' command */
 	ret = efi_bootmgr_run(EFI_FDT_USE_INTERNAL);
+	if (ret != EFI_SUCCESS)
+		return log_msg_ret("mgr",
+				   ret == EFI_NOT_FOUND ? -ENOENT : -EIO);
 
 	return 0;
 }
-- 
2.43.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.