summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Olbrich <m.olbrich@pengutronix.de>2017-01-23 18:02:18 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2017-01-24 09:34:11 +0100
commitaa6f3cc4b46c90c485aed7e183199871348c4821 (patch)
treef532e82439637d171f95798795b1b593a92edecb
parent71f0587f2049397d86e9eee7983bce623de5fb5e (diff)
downloadbarebox-aa6f3cc4b46c90c485aed7e183199871348c4821.tar.gz
barebox-aa6f3cc4b46c90c485aed7e183199871348c4821.tar.xz
efi: don't unload drivers
EFI applications should be unloaded to avoid leaking memory. However, boot or runtime services continue in the background. So they must not be unloaded. Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--arch/efi/efi/efi-image.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/arch/efi/efi/efi-image.c b/arch/efi/efi/efi-image.c
index c780cad6d4..27f3c1b39c 100644
--- a/arch/efi/efi/efi-image.c
+++ b/arch/efi/efi/efi-image.c
@@ -130,12 +130,16 @@ static int efi_execute_image(const char *file)
efi_status_t efiret;
struct linux_kernel_header *image_header;
const char *options;
+ bool is_driver;
int ret;
ret = efi_load_image(file, &loaded_image, &handle);
if (ret)
return ret;
+ is_driver = (loaded_image->image_code_type == EFI_BOOT_SERVICES_CODE) ||
+ (loaded_image->image_code_type == EFI_RUNTIME_SERVICES_CODE);
+
image_header = (struct linux_kernel_header *)loaded_image->image_base;
if (image_header->boot_flag == 0xAA55 &&
image_header->header == 0x53726448) {
@@ -152,7 +156,8 @@ static int efi_execute_image(const char *file)
if (EFI_ERROR(efiret))
pr_err("failed to StartImage: %s\n", efi_strerror(efiret));
- BS->unload_image(handle);
+ if (!is_driver)
+ BS->unload_image(handle);
efi_connect_all();
efi_register_devices();