[U-Boot] [PATCH 1/1] efi_loader: UninstallMultipleProtocolInterfaces error code

Heinrich Schuchardt xypron.glpk at gmx.de
Mon Sep 24 17:57:27 UTC 2018


If UninstallMultipleProtocolInterfaces fails, we sometimes return the wrong
status code. The UEFI spec mandates to always return EFI_INVALID_PARAMETER.

Update unit test.

Signed-off-by: Heinrich Schuchardt <xypron.glpk at gmx.de>
---
 lib/efi_loader/efi_boottime.c                  |  3 ++-
 .../efi_selftest_manageprotocols.c             | 18 +++++++++++++++---
 2 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
index ac724b17fd..554997f44a 100644
--- a/lib/efi_loader/efi_boottime.c
+++ b/lib/efi_loader/efi_boottime.c
@@ -2409,7 +2409,8 @@ static efi_status_t EFIAPI efi_uninstall_multiple_protocol_interfaces(
 	}
 	efi_va_end(argptr);
 
-	return EFI_EXIT(r);
+	/* In case of an error always return EFI_INVALID_PARAMETER */
+	return EFI_EXIT(EFI_INVALID_PARAMETER);
 }
 
 /**
diff --git a/lib/efi_selftest/efi_selftest_manageprotocols.c b/lib/efi_selftest/efi_selftest_manageprotocols.c
index b09e4cdcfa..0ff35cec8a 100644
--- a/lib/efi_selftest/efi_selftest_manageprotocols.c
+++ b/lib/efi_selftest/efi_selftest_manageprotocols.c
@@ -189,7 +189,14 @@ static int execute(void)
 	/*
 	 * Test error handling in UninstallMultipleProtocols
 	 *
-	 * Try to uninstall more protocols than there are installed.
+	 * These are the installed protocol interfaces on handle 2:
+	 *
+	 *   guid1 interface4
+	 *   guid2 interface2
+	 *
+	 * Try to uninstall more protocols than there are installed. This
+	 * should return an error EFI_INVALID_PARAMETER. All deleted protocols
+	 * should be reinstalled.
 	 */
 	ret = boottime->uninstall_multiple_protocol_interfaces(
 						handle2,
@@ -197,13 +204,18 @@ static int execute(void)
 						&guid2, &interface2,
 						&guid3, &interface3,
 						NULL);
-	if (ret == EFI_SUCCESS) {
+	if (ret != EFI_INVALID_PARAMETER) {
+		printf("%lx", ret);
 		efi_st_error("UninstallMultipleProtocolInterfaces did not catch error\n");
 		return EFI_ST_FAILURE;
 	}
 
 	/*
 	 * Test LocateHandleBuffer with ByProtocol
+	 *
+	 * These are the handles with a guid1 protocol interface installed:
+	 *
+	 *	handle1, handle2
 	 */
 	count = buffer_size;
 	ret = boottime->locate_handle_buffer(BY_PROTOCOL, &guid1, NULL,
@@ -213,7 +225,7 @@ static int execute(void)
 		return EFI_ST_FAILURE;
 	}
 	if (count != 2) {
-		efi_st_error("LocateHandleBuffer failed to locate new handles\n");
+		efi_st_error("UninstallMultipleProtocolInterfaces deleted handle\n");
 		return EFI_ST_FAILURE;
 	}
 	ret = find_in_buffer(handle1, count, buffer);
-- 
2.19.0



More information about the U-Boot mailing list