]> git.proxmox.com Git - mirror_edk2.git/commitdiff
SecurityPkg/TcgPhysicalPresenceLib: Replace the ASSERT with error code
authorZhichao Gao <zhichao.gao@intel.com>
Mon, 16 Dec 2019 01:18:55 +0000 (09:18 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Fri, 7 Feb 2020 07:22:11 +0000 (07:22 +0000)
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2472

Replace the ASSERT with the error code return in the TpmPhysicalPresence
and GetTpmCapability.
Add missing error checking after call TpmPhysicalPresence in
TcgPhysicalPresenceLibProcessRequest.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Chao Zhang <chao.b.zhang@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Signed-off-by: Zhichao Gao <zhichao.gao@intel.com>
SecurityPkg/Library/DxeTcgPhysicalPresenceLib/DxeTcgPhysicalPresenceLib.c

index 174172d5d7a55ea93c5d2e54f59405b823f64507..7cd3ddfc1b96ad2042cf9ab10198b8edee2d5b52 100644 (file)
@@ -102,9 +102,13 @@ GetTpmCapability (
                           sizeof (RecvBuffer),\r
                           (UINT8*)&RecvBuffer\r
                           );\r
-  ASSERT_EFI_ERROR (Status);\r
-  ASSERT (TpmRsp->tag == SwapBytes16 (TPM_TAG_RSP_COMMAND));\r
-  ASSERT (TpmRsp->returnCode == 0);\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  if ((TpmRsp->tag != SwapBytes16 (TPM_TAG_RSP_COMMAND)) || (TpmRsp->returnCode != 0)) {\r
+    return EFI_DEVICE_ERROR;\r
+  }\r
 \r
   TpmPermanentFlags = (TPM_PERMANENT_FLAGS *)&RecvBuffer[sizeof (TPM_RSP_COMMAND_HDR) + sizeof (UINT32)];\r
 \r
@@ -157,8 +161,14 @@ TpmPhysicalPresence (
                           sizeof (TpmRsp),\r
                           (UINT8*)&TpmRsp\r
                           );\r
-  ASSERT_EFI_ERROR (Status);\r
-  ASSERT (TpmRsp.tag == SwapBytes16 (TPM_TAG_RSP_COMMAND));\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  if (TpmRsp.tag != SwapBytes16 (TPM_TAG_RSP_COMMAND)) {\r
+    return EFI_DEVICE_ERROR;\r
+  }\r
+\r
   if (TpmRsp.returnCode != 0) {\r
     //\r
     // If it fails, some requirements may be needed for this command.\r
@@ -1273,7 +1283,10 @@ TcgPhysicalPresenceLibProcessRequest (
   //\r
   // Set operator physical presence flags\r
   //\r
-  TpmPhysicalPresence (TcgProtocol, TPM_PHYSICAL_PRESENCE_PRESENT);\r
+  Status = TpmPhysicalPresence (TcgProtocol, TPM_PHYSICAL_PRESENCE_PRESENT);\r
+  if (EFI_ERROR (Status)) {\r
+    return;\r
+  }\r
 \r
   //\r
   // Execute pending TPM request.\r