diff --git a/stand/efi/loader/main.c b/stand/efi/loader/main.c --- a/stand/efi/loader/main.c +++ b/stand/efi/loader/main.c @@ -1903,7 +1903,8 @@ status = BS->LoadImage(FALSE, IH, NULL, buf, st.st_size, &loaderhandle); (void)BS->FreePool(buf); if (status != EFI_SUCCESS) { - command_errmsg = "LoadImage failed"; + printf("LoadImage failed: status code: %lu\n", + EFI_ERROR_CODE(status)); return (CMD_ERROR); } status = OpenProtocolByHandle(loaderhandle, &LoadedImageGUID, @@ -1918,6 +1919,11 @@ len *= sizeof (*argp); loaded_image->LoadOptions = argp = malloc (len); + if (loaded_image->LoadOptions == NULL) { + command_errmsg = "Adding LoadOptions: out of memory"; + (void) BS->UnloadImage(loaded_image); + return (CMD_ERROR); + } loaded_image->LoadOptionsSize = len; for (i = 2; i < argc; i++) { char *ptr = argv[i]; @@ -1971,7 +1977,8 @@ dev_cleanup(); status = BS->StartImage(loaderhandle, NULL, NULL); if (status != EFI_SUCCESS) { - command_errmsg = "StartImage failed"; + printf("StartImage failed: status code: %lu\n", + EFI_ERROR_CODE(status)); free(loaded_image->LoadOptions); loaded_image->LoadOptions = NULL; status = BS->UnloadImage(loaded_image);