From nobody Thu May 2 21:11:41 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1518163430156605.0901356308459; Fri, 9 Feb 2018 00:03:50 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id C0999223DB796; Thu, 8 Feb 2018 23:58:02 -0800 (PST) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id A8701223DB78C for ; Thu, 8 Feb 2018 23:58:01 -0800 (PST) Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Feb 2018 00:03:47 -0800 Received: from shwdeopenpsi114.ccr.corp.intel.com ([10.239.157.135]) by fmsmga005.fm.intel.com with ESMTP; 09 Feb 2018 00:03:46 -0800 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.43; helo=mga05.intel.com; envelope-from=dandan.bi@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,482,1511856000"; d="scan'208";a="202604111" From: Dandan Bi To: edk2-devel@lists.01.org Date: Fri, 9 Feb 2018 16:03:38 +0800 Message-Id: <1518163418-23228-1-git-send-email-dandan.bi@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.1 Subject: [edk2] [patch] MdeModulePkg/PerfLib: Add NULL pointer check for "Token" X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jiewen Yao , Star Zeng , Liming Gao MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" "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 Cc: Star Zeng Cc: Jiewen Yao Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi Reviewed-by: Liming Gao --- 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/DxeCorePerformanceL= ib.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 =3D=3D NULL) { + return FALSE; + } + if (AsciiStrCmp (Token, SEC_TOK) =3D=3D 0 || AsciiStrCmp (Token, PEI_TOK) =3D=3D 0 || AsciiStrCmp (Token, DXE_TOK) =3D=3D 0 || AsciiStrCmp (Token, BDS_TOK) =3D=3D 0 || AsciiStrCmp (Token, DRIVERBINDING_START_TOK) =3D=3D 0 || @@ -845,11 +849,11 @@ InsertFpdtMeasurement ( return Status; } =20 // // 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 hav= e same + // !!! Note: If the Perf is not the known Token used in the core but hav= e 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/M= deModulePkg/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 b= y core. BOOLEAN IsKnownTokens ( IN CONST CHAR8 *Token ) { + if (Token =3D=3D NULL) { + return FALSE; + } + if (AsciiStrCmp (Token, SEC_TOK) =3D=3D 0 || AsciiStrCmp (Token, PEI_TOK) =3D=3D 0 || AsciiStrCmp (Token, DXE_TOK) =3D=3D 0 || AsciiStrCmp (Token, BDS_TOK) =3D=3D 0 || AsciiStrCmp (Token, DRIVERBINDING_START_TOK) =3D=3D 0 || @@ -264,11 +268,11 @@ InsertPeiFpdtMeasurement ( return Status; } =20 // // 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 hav= e same + // !!! Note: If the Perf is not the known Token used in the core but hav= e 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/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 b= y core. BOOLEAN IsKnownTokens ( IN CONST CHAR8 *Token ) { + if (Token =3D=3D NULL) { + return FALSE; + } + if (AsciiStrCmp (Token, SEC_TOK) =3D=3D 0 || AsciiStrCmp (Token, PEI_TOK) =3D=3D 0 || AsciiStrCmp (Token, DXE_TOK) =3D=3D 0 || AsciiStrCmp (Token, BDS_TOK) =3D=3D 0 || AsciiStrCmp (Token, DRIVERBINDING_START_TOK) =3D=3D 0 || @@ -495,11 +499,11 @@ InsertFpdtMeasurement ( return Status; } =20 // // 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 hav= e same + // !!! Note: If the Perf is not the known Token used in the core but hav= e 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. --=20 1.9.5.msysgit.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel