summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/efi_selftest/efi_selftest_block_device.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/efi_selftest/efi_selftest_block_device.c b/lib/efi_selftest/efi_selftest_block_device.c
index 9c4be834eeb..b5f6f9353cd 100644
--- a/lib/efi_selftest/efi_selftest_block_device.c
+++ b/lib/efi_selftest/efi_selftest_block_device.c
@@ -58,6 +58,9 @@ static const struct compressed_disk_image img = EFI_ST_DISK_IMG;
/* Decompressed disk image */
static u8 *image;
+/* Handles buffer */
+static efi_handle_t *handles;
+
/*
* Reset service of the block IO protocol.
*
@@ -276,6 +279,15 @@ static int teardown(void)
return EFI_ST_FAILURE;
}
}
+
+ if (handles) {
+ r = boottime->free_pool(handles);
+ if (r != EFI_SUCCESS) {
+ efi_st_error("Failed to free handles\n");
+ return EFI_ST_FAILURE;
+ }
+ }
+
return r;
}
@@ -303,7 +315,6 @@ static int execute(void)
{
efi_status_t ret;
efi_uintn_t no_handles, i, len;
- efi_handle_t *handles;
efi_handle_t handle_partition = NULL;
struct efi_device_path *dp_partition;
struct efi_block_io *block_io_protocol;
@@ -372,6 +383,7 @@ static int execute(void)
break;
}
ret = boottime->free_pool(handles);
+ handles = NULL; /* Avoid double free on teardown(). */
if (ret != EFI_SUCCESS) {
efi_st_error("Failed to free pool memory\n");
return EFI_ST_FAILURE;