[edk2-devel] [PATCH] SecurityPkg/Tcg/Tcg2Config: Fix REVERSE_INULL Coverity issue

Ranbir Singh via groups.io posted 1 patch 1 year, 4 months ago
Failed in applying to current master (apply log)
SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigDriver.c | 4 ++++
1 file changed, 4 insertions(+)
[edk2-devel] [PATCH] SecurityPkg/Tcg/Tcg2Config: Fix REVERSE_INULL Coverity issue
Posted by Ranbir Singh via groups.io 1 year, 4 months ago
The function Tcg2ConfigDriverEntryPoint at the point of creating a
private data structure makes a call to AllocateCopyPool and stores
the return value in PrivateData. Thereafter it does a check

ASSERT (PrivateData != NULL);

but this is applicable only in DEBUG mode. In Release mode, the code
continues further and will dereference "PrivateData" which will lead
to CRASH if PrivateData is NULL.

Hence, for safety add PrivateData NULL pointer check and return from
there saying EFI_OUT_OF_RESOURCES when PrivateData is NULL.

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4229
Signed-off-by: Ranbir Singh <Ranbir.Singh3@Dell.com>
---
SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigDriver.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigDriver.c b/SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigDriver.c
index edf5f0fc77..f023b3ccb8 100644
--- a/SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigDriver.c
+++ b/SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigDriver.c
@@ -283,6 +283,10 @@ Tcg2ConfigDriverEntryPoint (
//
PrivateData = AllocateCopyPool (sizeof (TCG2_CONFIG_PRIVATE_DATA), &mTcg2ConfigPrivateDateTemplate);
ASSERT (PrivateData != NULL);
+  if (PrivateData == NULL) {
+    return EFI_OUT_OF_RESOURCES;
+  }
+
mTcg2ConfigPrivateDate = PrivateData;
//
// Install private GUID.
--
2.36.1.windows.1


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