diff options
author | Pierre Gondois <pierre.gondois@arm.com> | 2022-11-24 17:17:55 +0100 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2023-03-07 15:34:23 +0000 |
commit | 75fb0cfc82376906243386514be0e4067d702117 (patch) | |
tree | be3e93f1fdb02bcec8f1db951234175524b8b949 | |
parent | bfb574db110899471fe09db819587b3151c7b7b5 (diff) | |
download | edk2-75fb0cfc82376906243386514be0e4067d702117.tar.gz |
SecurityPkg/RngDxe: Conditionally install EFI_RNG_PROTOCOL
On Arm platforms, the number of available RNG algorithms is
dynamically detected and can be 0 in the absence of FEAT_RNG
and firmware TRNG.
In this case, the EFI_RNG_PROTOCOL should not be installed to
prevent from installing an empty protocol.
Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com>
[ardb: return EFI_REQUEST_UNLOAD_IMAGE instead of an error]
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
-rw-r--r-- | SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.c b/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.c index 421abb52b8..292338b7d0 100644 --- a/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.c +++ b/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.c @@ -64,6 +64,18 @@ RngDriverEntry ( EFI_HANDLE Handle;
//
+ // Get the list of available algorithm.
+ //
+ Status = GetAvailableAlgorithms ();
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ if (mAvailableAlgoArrayCount == 0) {
+ return EFI_REQUEST_UNLOAD_IMAGE;
+ }
+
+ //
// Install UEFI RNG (Random Number Generator) Protocol
//
Handle = NULL;
@@ -74,13 +86,10 @@ RngDriverEntry ( NULL
);
if (EFI_ERROR (Status)) {
- return Status;
+ FreeAvailableAlgorithms ();
}
- //
- // Get the list of available algorithm.
- //
- return GetAvailableAlgorithms ();
+ return Status;
}
/**
|