[Concept,22/24] efi: app: Call efi_exit() if board_init_r() returns

Message ID 20250922180116.3088502-23-sjg@u-boot.org
State New
Headers
Series boot: efi: Various improvements to booting with the EFI app |

Commit Message

Simon Glass Sept. 22, 2025, 6:01 p.m. UTC
  From: Simon Glass <sjg@chromium.org>

Move the efi_exit() function further up the file and call it if the
board_init_r() function returns.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 lib/efi_client/efi_app.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)
  

Patch

diff --git a/lib/efi_client/efi_app.c b/lib/efi_client/efi_app.c
index 25fc2e9cade..b99de578fac 100644
--- a/lib/efi_client/efi_app.c
+++ b/lib/efi_client/efi_app.c
@@ -185,6 +185,14 @@  static void find_protocols(struct efi_priv *priv)
 	boot->locate_protocol(&guid, NULL, (void **)&priv->efi_dp_to_text);
 }
 
+static void efi_exit(void)
+{
+	struct efi_priv *priv = efi_get_priv();
+
+	printf("U-Boot EFI exiting\n");
+	priv->boot->exit(priv->parent_image, EFI_SUCCESS, 0, NULL);
+}
+
 /**
  * efi_main() - Start an EFI image
  *
@@ -237,18 +245,11 @@  efi_status_t EFIAPI efi_main(efi_handle_t image,
 	gd = gd->new_gd;
 	board_init_r(NULL, 0);
 	free_memory(priv);
+	efi_exit();
 
 	return EFI_SUCCESS;
 }
 
-static void efi_exit(void)
-{
-	struct efi_priv *priv = efi_get_priv();
-
-	printf("U-Boot EFI exiting\n");
-	priv->boot->exit(priv->parent_image, EFI_SUCCESS, 0, NULL);
-}
-
 static int efi_sysreset_request(struct udevice *dev, enum sysreset_t type)
 {
 	struct efi_priv *priv = efi_get_priv();