public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [patch] MdeModulePkg/PerfLib: Add NULL pointer check for "Token"
@ 2018-02-09  8:03 Dandan Bi
  2018-02-09  9:20 ` Gao, Liming
  0 siblings, 1 reply; 2+ messages in thread
From: Dandan Bi @ 2018-02-09  8:03 UTC (permalink / raw)
  To: edk2-devel; +Cc: Liming Gao, Star Zeng, Jiewen Yao

"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



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [patch] MdeModulePkg/PerfLib: Add NULL pointer check for "Token"
  2018-02-09  8:03 [patch] MdeModulePkg/PerfLib: Add NULL pointer check for "Token" Dandan Bi
@ 2018-02-09  9:20 ` Gao, Liming
  0 siblings, 0 replies; 2+ messages in thread
From: Gao, Liming @ 2018-02-09  9:20 UTC (permalink / raw)
  To: Bi, Dandan, edk2-devel@lists.01.org; +Cc: Yao, Jiewen, Zeng, Star

Reviewed-by: Liming Gao <liming.gao@intel.com>

>-----Original Message-----
>From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of
>Dandan Bi
>Sent: Friday, February 09, 2018 4:04 PM
>To: edk2-devel@lists.01.org
>Cc: Yao, Jiewen <jiewen.yao@intel.com>; Zeng, Star <star.zeng@intel.com>;
>Gao, Liming <liming.gao@intel.com>
>Subject: [edk2] [patch] MdeModulePkg/PerfLib: Add NULL pointer check for
>"Token"
>
>"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/SmmCorePerformanceL
>ib.c
>b/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceL
>ib.c
>index 2834a68..dbc1166 100644
>---
>a/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceL
>ib.c
>+++
>b/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceL
>ib.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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-02-09  9:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-09  8:03 [patch] MdeModulePkg/PerfLib: Add NULL pointer check for "Token" Dandan Bi
2018-02-09  9:20 ` Gao, Liming

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox