[U-Boot,1/3] efi_loader: return status from efi_setup_loaded_image()

Message ID 20171204170303.24758-2-xypron.glpk@gmx.de
State New
Delegated to: Alexander Graf
Headers show
Series
  • efi_loader: avoid use after free
Related show

Commit Message

Heinrich Schuchardt Dec. 4, 2017, 5:03 p.m.
efi_setup_loaded_image() should return an error code indicating if
an error has occurred.

An error occurs if a protocol cannot be installed.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
---
 include/efi_loader.h          |  8 +++++---
 lib/efi_loader/efi_boottime.c | 11 +++++++----
 2 files changed, 12 insertions(+), 7 deletions(-)

Patch

diff --git a/include/efi_loader.h b/include/efi_loader.h
index c0caabddb1..78237f14ae 100644
--- a/include/efi_loader.h
+++ b/include/efi_loader.h
@@ -249,9 +249,11 @@  uint64_t efi_add_memory_map(uint64_t start, uint64_t pages, int memory_type,
 int efi_memory_init(void);
 /* Adds new or overrides configuration table entry to the system table */
 efi_status_t efi_install_configuration_table(const efi_guid_t *guid, void *table);
-void efi_setup_loaded_image(struct efi_loaded_image *info, struct efi_object *obj,
-			    struct efi_device_path *device_path,
-			    struct efi_device_path *file_path);
+/* Sets up a loaded image */
+efi_status_t efi_setup_loaded_image(
+			struct efi_loaded_image *info, struct efi_object *obj,
+			struct efi_device_path *device_path,
+			struct efi_device_path *file_path);
 efi_status_t efi_load_image_from_path(struct efi_device_path *file_path,
 				      void **buffer);
 
diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
index a37fb25638..a9ba1ac394 100644
--- a/lib/efi_loader/efi_boottime.c
+++ b/lib/efi_loader/efi_boottime.c
@@ -1170,10 +1170,12 @@  static efi_status_t EFIAPI efi_install_configuration_table_ext(efi_guid_t *guid,
  * @obj			internal object associated with the loaded image
  * @device_path		device path of the loaded image
  * @file_path		file path of the loaded image
+ * @return		status code
  */
-void efi_setup_loaded_image(struct efi_loaded_image *info, struct efi_object *obj,
-			    struct efi_device_path *device_path,
-			    struct efi_device_path *file_path)
+efi_status_t efi_setup_loaded_image(
+			struct efi_loaded_image *info, struct efi_object *obj,
+			struct efi_device_path *device_path,
+			struct efi_device_path *file_path)
 {
 	efi_status_t ret;
 
@@ -1213,9 +1215,10 @@  void efi_setup_loaded_image(struct efi_loaded_image *info, struct efi_object *ob
 	if (ret != EFI_SUCCESS)
 		goto failure;
 
-	return;
+	return ret;
 failure:
 	printf("ERROR: Failure to install protocols for loaded image\n");
+	return ret;
 }
 
 /*