]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg/PerfLib: Add NULL pointer check for "Token"
authorDandan Bi <dandan.bi@intel.com>
Fri, 9 Feb 2018 05:21:08 +0000 (13:21 +0800)
committerStar Zeng <star.zeng@intel.com>
Sun, 11 Feb 2018 01:56:01 +0000 (09:56 +0800)
"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.gao@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c
MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c
MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c

index 8363b0e4ed5ceae5acbaabb687a6cd63fefba5d3..9b3224ef6faf5917e55e1fbbfb7e59dc2a61766d 100644 (file)
@@ -115,6 +115,10 @@ IsKnownTokens (
   IN CONST CHAR8  *Token\r
   )\r
 {\r
+  if (Token == NULL) {\r
+    return FALSE;\r
+  }\r
+\r
   if (AsciiStrCmp (Token, SEC_TOK) == 0 ||\r
       AsciiStrCmp (Token, PEI_TOK) == 0 ||\r
       AsciiStrCmp (Token, DXE_TOK) == 0 ||\r
@@ -847,7 +851,7 @@ InsertFpdtMeasurement (
 \r
   //\r
   // If PERF_START()/PERF_END() have specified the ProgressID,it has high priority.\r
-  // !!! Note: If the Pref is not the known Token used in the core but have same\r
+  // !!! Note: If the Perf is not the known Token used in the core but have same\r
   // ID with the core Token, this case will not be supported.\r
   // And in currtnt usage mode, for the unkown ID, there is a general rule:\r
   // If it is start pref: the lower 4 bits of the ID should be 0.\r
index 79b67e850610b0690b358ba087be0900c36fda09..f770a35a995d7a8f8a399f4dd4f1a38244b7cfac 100644 (file)
@@ -49,6 +49,10 @@ IsKnownTokens (
   IN CONST CHAR8  *Token\r
   )\r
 {\r
+  if (Token == NULL) {\r
+    return FALSE;\r
+  }\r
+\r
   if (AsciiStrCmp (Token, SEC_TOK) == 0 ||\r
       AsciiStrCmp (Token, PEI_TOK) == 0 ||\r
       AsciiStrCmp (Token, DXE_TOK) == 0 ||\r
@@ -266,7 +270,7 @@ InsertPeiFpdtMeasurement (
 \r
   //\r
   // If PERF_START()/PERF_END() have specified the ProgressID,it has high priority.\r
-  // !!! Note: If the Pref is not the known Token used in the core but have same\r
+  // !!! Note: If the Perf is not the known Token used in the core but have same\r
   // ID with the core Token, this case will not be supported.\r
   // And in currtnt usage mode, for the unkown ID, there is a general rule:\r
   // If it is start pref: the lower 4 bits of the ID should be 0.\r
index 2834a685d7ee266bf84297741948ffc62da96a61..dbc1166f254a2cd3c3d4cc823b58c9c7c7d602ab 100644 (file)
@@ -85,6 +85,10 @@ IsKnownTokens (
   IN CONST CHAR8  *Token\r
   )\r
 {\r
+  if (Token == NULL) {\r
+    return FALSE;\r
+  }\r
+\r
   if (AsciiStrCmp (Token, SEC_TOK) == 0 ||\r
       AsciiStrCmp (Token, PEI_TOK) == 0 ||\r
       AsciiStrCmp (Token, DXE_TOK) == 0 ||\r
@@ -497,7 +501,7 @@ InsertFpdtMeasurement (
 \r
   //\r
   // If PERF_START()/PERF_END() have specified the ProgressID,it has high priority.\r
-  // !!! Note: If the Pref is not the known Token used in the core but have same\r
+  // !!! Note: If the Perf is not the known Token used in the core but have same\r
   // ID with the core Token, this case will not be supported.\r
   // And in currtnt usage mode, for the unkown ID, there is a general rule:\r
   // If it is start pref: the lower 4 bits of the ID should be 0.\r