summaryrefslogtreecommitdiffstats
path: root/src/arch/x86/prefix/efiprefix.c
diff options
context:
space:
mode:
authorMichael Brown2014-03-14 16:56:36 +0100
committerMichael Brown2014-03-14 17:20:55 +0100
commitf618178e60702c0ccb2501976bad36d483134938 (patch)
tree67319c2d3e9af59dad1cf9cbbf1f1a4ee5f7590a /src/arch/x86/prefix/efiprefix.c
parent[efi] Avoid accidentally calling main() twice (diff)
downloadipxe-f618178e60702c0ccb2501976bad36d483134938.tar.gz
ipxe-f618178e60702c0ccb2501976bad36d483134938.tar.xz
ipxe-f618178e60702c0ccb2501976bad36d483134938.zip
[efi] Unload our own image before exiting UEFI application
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/arch/x86/prefix/efiprefix.c')
-rw-r--r--src/arch/x86/prefix/efiprefix.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/arch/x86/prefix/efiprefix.c b/src/arch/x86/prefix/efiprefix.c
index 475ea505..eb8aa738 100644
--- a/src/arch/x86/prefix/efiprefix.c
+++ b/src/arch/x86/prefix/efiprefix.c
@@ -37,11 +37,16 @@ EFI_STATUS EFIAPI _efi_start ( EFI_HANDLE image_handle,
/* Initialise EFI environment */
if ( ( efirc = efi_init ( image_handle, systab ) ) != 0 )
- return efirc;
+ goto err_init;
/* Call to main() */
- if ( ( rc = main() ) != 0 )
- return EFIRC ( rc );
+ if ( ( rc = main() ) != 0 ) {
+ efirc = EFIRC ( rc );
+ goto err_main;
+ }
- return 0;
+ err_main:
+ efi_loaded_image->Unload ( image_handle );
+ err_init:
+ return efirc;
}