[edk2-devel] [PATCH V1] SecurityPkg: Fix return handling in RdRandGenerateEntropy

Bjorge, Erik C posted 1 patch 1 year, 5 months ago
Failed in applying to current master (apply log)
.../PeiDxeTpmPlatformHierarchyLib.c                | 14 +++++---------
1 file changed, 5 insertions(+), 9 deletions(-)
[edk2-devel] [PATCH V1] SecurityPkg: Fix return handling in RdRandGenerateEntropy
Posted by Bjorge, Erik C 1 year, 5 months ago
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4090

The function GetRandomNumber128 returns a BOOLEAN and not EFI_STATUS.
Update the code to correctly handle the BOOLEAN return type.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Signed-off-by: Erik Bjorge <erik.c.bjorge@intel.com>
---
 .../PeiDxeTpmPlatformHierarchyLib.c                | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/SecurityPkg/Library/PeiDxeTpmPlatformHierarchyLib/PeiDxeTpmPlatformHierarchyLib.c b/SecurityPkg/Library/PeiDxeTpmPlatformHierarchyLib/PeiDxeTpmPlatformHierarchyLib.c
index b8838766bc..8e3b7ce9fd 100644
--- a/SecurityPkg/Library/PeiDxeTpmPlatformHierarchyLib/PeiDxeTpmPlatformHierarchyLib.c
+++ b/SecurityPkg/Library/PeiDxeTpmPlatformHierarchyLib/PeiDxeTpmPlatformHierarchyLib.c
@@ -46,12 +46,10 @@ RdRandGenerateEntropy (
   OUT UINT8  *Entropy
   )
 {
-  EFI_STATUS  Status;
   UINTN       BlockCount;
   UINT64      Seed[2];
   UINT8       *Ptr;
 
-  Status     = EFI_NOT_READY;
   BlockCount = Length / sizeof (Seed);
   Ptr        = (UINT8 *)Entropy;
 
@@ -59,9 +57,8 @@ RdRandGenerateEntropy (
   // Generate high-quality seed for DRBG Entropy
   //
   while (BlockCount > 0) {
-    Status = GetRandomNumber128 (Seed);
-    if (EFI_ERROR (Status)) {
-      return Status;
+    if (!GetRandomNumber128 (Seed)) {
+      return EFI_NOT_READY;
     }
 
     CopyMem (Ptr, Seed, sizeof (Seed));
@@ -73,14 +70,13 @@ RdRandGenerateEntropy (
   //
   // Populate the remained data as request.
   //
-  Status = GetRandomNumber128 (Seed);
-  if (EFI_ERROR (Status)) {
-    return Status;
+  if (!GetRandomNumber128 (Seed)) {
+    return EFI_NOT_READY;
   }
 
   CopyMem (Ptr, Seed, (Length % sizeof (Seed)));
 
-  return Status;
+  return EFI_SUCCESS;
 }
 
 /**
-- 
2.36.0.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#95622): https://edk2.groups.io/g/devel/message/95622
Mute This Topic: https://groups.io/mt/94591739/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-