public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Bjorge, Erik C" <erik.c.bjorge@intel.com>
To: devel@edk2.groups.io
Cc: Erik Bjorge <erik.c.bjorge@intel.com>,
	Jiewen Yao <jiewen.yao@intel.com>,
	Jian J Wang <jian.j.wang@intel.com>
Subject: [PATCH V1] SecurityPkg: Fix return handling in RdRandGenerateEntropy
Date: Wed, 26 Oct 2022 14:23:44 -0700	[thread overview]
Message-ID: <91a69f0b059217210234eef8cac8ee37df7a152e.1666819264.git.erik.c.bjorge@intel.com> (raw)

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


                 reply	other threads:[~2022-10-26 21:24 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=91a69f0b059217210234eef8cac8ee37df7a152e.1666819264.git.erik.c.bjorge@intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox