diff mbox series

efi_selftests: fix protocol repeated selftesting

Message ID 20230613132306.83940-2-ilias.apalodimas@linaro.org
State Accepted
Commit 5669591dd8d2b21bc79237b161107300eb7f2b12
Headers show
Series efi_selftests: fix protocol repeated selftesting | expand

Commit Message

Ilias Apalodimas June 13, 2023, 1:23 p.m. UTC
Running the protocols  selftest more than one times fails with

=> setenv efi_selftest 'manage protocols' && bootefi selftest
Testing EFI API implementation
Selected test: 'manage protocols'
Setting up 'manage protocols'
Setting up 'manage protocols' succeeded
Executing 'manage protocols'
Executing 'manage protocols' succeeded
Tearing down 'manage protocols'
Tearing down 'manage protocols' succeeded
Summary: 0 failures

=> bootefi selftest
Testing EFI API implementation
Selected test: 'manage protocols'
Setting up 'manage protocols'
lib/efi_selftest/efi_selftest_manageprotocols.c(88):
ERROR: InstallProtocolInterface failed
lib/efi_selftest/efi_selftest.c(89):
ERROR: Setting up 'manage protocols' failed
Tearing down 'manage protocols'
Tearing down 'manage protocols' succeeded
Summary: 1 failures

The reason is that we don't set the handles to NULL after deleting and
freeing them.  As a result the subsequent protocol installation will try
to use an existing handle which we just removed that from our object list.

Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
---
 lib/efi_selftest/efi_selftest_manageprotocols.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Heinrich Schuchardt June 16, 2023, 5:21 a.m. UTC | #1
On 6/13/23 15:23, Ilias Apalodimas wrote:
> Running the protocols  selftest more than one times fails with
>
> => setenv efi_selftest 'manage protocols' && bootefi selftest
> Testing EFI API implementation
> Selected test: 'manage protocols'
> Setting up 'manage protocols'
> Setting up 'manage protocols' succeeded
> Executing 'manage protocols'
> Executing 'manage protocols' succeeded
> Tearing down 'manage protocols'
> Tearing down 'manage protocols' succeeded
> Summary: 0 failures
>
> => bootefi selftest
> Testing EFI API implementation
> Selected test: 'manage protocols'
> Setting up 'manage protocols'
> lib/efi_selftest/efi_selftest_manageprotocols.c(88):
> ERROR: InstallProtocolInterface failed
> lib/efi_selftest/efi_selftest.c(89):
> ERROR: Setting up 'manage protocols' failed
> Tearing down 'manage protocols'
> Tearing down 'manage protocols' succeeded
> Summary: 1 failures
>
> The reason is that we don't set the handles to NULL after deleting and
> freeing them.  As a result the subsequent protocol installation will try
> to use an existing handle which we just removed that from our object list.
>
> Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>

Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
diff mbox series

Patch

diff --git a/lib/efi_selftest/efi_selftest_manageprotocols.c b/lib/efi_selftest/efi_selftest_manageprotocols.c
index 8edb1e4d4671..097b2ae35456 100644
--- a/lib/efi_selftest/efi_selftest_manageprotocols.c
+++ b/lib/efi_selftest/efi_selftest_manageprotocols.c
@@ -79,6 +79,8 @@  static int setup(const efi_handle_t img_handle,
 	efi_status_t ret;
 	efi_handle_t handle;
 
+	handle1 = NULL;
+	handle2 = NULL;
 	boottime = systable->boottime;
 
 	ret = boottime->install_protocol_interface(&handle1, &guid3,