public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Dandan Bi <dandan.bi@intel.com>
To: edk2-devel@lists.01.org
Cc: Liming Gao <liming.gao@intel.com>,
	Star Zeng <star.zeng@intel.com>,
	Jiewen Yao <jiewen.yao@intel.com>
Subject: [patch] MdeModulePkg/PerfLib: Add NULL pointer check for "Token"
Date: Fri,  9 Feb 2018 16:03:38 +0800	[thread overview]
Message-ID: <1518163418-23228-1-git-send-email-dandan.bi@intel.com> (raw)

"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>
---
 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



             reply	other threads:[~2018-02-09  7:58 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-09  8:03 Dandan Bi [this message]
2018-02-09  9:20 ` [patch] MdeModulePkg/PerfLib: Add NULL pointer check for "Token" Gao, Liming

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=1518163418-23228-1-git-send-email-dandan.bi@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