"Token" is passed through the perf entry, it's may be NULL.
So we need to add NULL pointer check before reference it.

Cc: Liming Gao <liming....@intel.com>
Cc: Star Zeng <star.z...@intel.com>
Cc: Jiewen Yao <jiewen....@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi <dandan...@intel.com>
---
 MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c | 6 +++++-
 MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c         | 6 +++++-
 MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c | 6 +++++-
 3 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c 
b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c
index 8363b0e..9b3224e 100644
--- a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c
+++ b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c
@@ -113,10 +113,14 @@ Check whether the Token is a known one which is uesed by 
core.
 BOOLEAN
 IsKnownTokens (
   IN CONST CHAR8  *Token
   )
 {
+  if (Token == NULL) {
+    return FALSE;
+  }
+
   if (AsciiStrCmp (Token, SEC_TOK) == 0 ||
       AsciiStrCmp (Token, PEI_TOK) == 0 ||
       AsciiStrCmp (Token, DXE_TOK) == 0 ||
       AsciiStrCmp (Token, BDS_TOK) == 0 ||
       AsciiStrCmp (Token, DRIVERBINDING_START_TOK) == 0 ||
@@ -845,11 +849,11 @@ InsertFpdtMeasurement (
     return Status;
   }
 
   //
   // If PERF_START()/PERF_END() have specified the ProgressID,it has high 
priority.
-  // !!! Note: If the Pref is not the known Token used in the core but have 
same
+  // !!! Note: If the Perf is not the known Token used in the core but have 
same
   // ID with the core Token, this case will not be supported.
   // And in currtnt usage mode, for the unkown ID, there is a general rule:
   // If it is start pref: the lower 4 bits of the ID should be 0.
   // If it is end pref: the lower 4 bits of the ID should not be 0.
   // If input ID doesn't follow the rule, we will adjust it.
diff --git a/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c 
b/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c
index 79b67e8..f770a35 100644
--- a/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c
+++ b/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c
@@ -47,10 +47,14 @@ Check whether the Token is a known one which is uesed by 
core.
 BOOLEAN
 IsKnownTokens (
   IN CONST CHAR8  *Token
   )
 {
+  if (Token == NULL) {
+    return FALSE;
+  }
+
   if (AsciiStrCmp (Token, SEC_TOK) == 0 ||
       AsciiStrCmp (Token, PEI_TOK) == 0 ||
       AsciiStrCmp (Token, DXE_TOK) == 0 ||
       AsciiStrCmp (Token, BDS_TOK) == 0 ||
       AsciiStrCmp (Token, DRIVERBINDING_START_TOK) == 0 ||
@@ -264,11 +268,11 @@ InsertPeiFpdtMeasurement (
     return Status;
   }
 
   //
   // If PERF_START()/PERF_END() have specified the ProgressID,it has high 
priority.
-  // !!! Note: If the Pref is not the known Token used in the core but have 
same
+  // !!! Note: If the Perf is not the known Token used in the core but have 
same
   // ID with the core Token, this case will not be supported.
   // And in currtnt usage mode, for the unkown ID, there is a general rule:
   // If it is start pref: the lower 4 bits of the ID should be 0.
   // If it is end pref: the lower 4 bits of the ID should not be 0.
   // If input ID doesn't follow the rule, we will adjust it.
diff --git a/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c 
b/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c
index 2834a68..dbc1166 100644
--- a/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c
+++ b/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c
@@ -83,10 +83,14 @@ Check whether the Token is a known one which is uesed by 
core.
 BOOLEAN
 IsKnownTokens (
   IN CONST CHAR8  *Token
   )
 {
+  if (Token == NULL) {
+    return FALSE;
+  }
+
   if (AsciiStrCmp (Token, SEC_TOK) == 0 ||
       AsciiStrCmp (Token, PEI_TOK) == 0 ||
       AsciiStrCmp (Token, DXE_TOK) == 0 ||
       AsciiStrCmp (Token, BDS_TOK) == 0 ||
       AsciiStrCmp (Token, DRIVERBINDING_START_TOK) == 0 ||
@@ -495,11 +499,11 @@ InsertFpdtMeasurement (
     return Status;
   }
 
   //
   // If PERF_START()/PERF_END() have specified the ProgressID,it has high 
priority.
-  // !!! Note: If the Pref is not the known Token used in the core but have 
same
+  // !!! Note: If the Perf is not the known Token used in the core but have 
same
   // ID with the core Token, this case will not be supported.
   // And in currtnt usage mode, for the unkown ID, there is a general rule:
   // If it is start pref: the lower 4 bits of the ID should be 0.
   // If it is end pref: the lower 4 bits of the ID should not be 0.
   // If input ID doesn't follow the rule, we will adjust it.
-- 
1.9.5.msysgit.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to