From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.120, mailfrom: chasel.chiu@intel.com) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by groups.io with SMTP; Tue, 17 Sep 2019 22:52:15 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Sep 2019 22:52:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,519,1559545200"; d="scan'208";a="270765827" Received: from pgsmsx112.gar.corp.intel.com ([10.108.55.201]) by orsmga001.jf.intel.com with ESMTP; 17 Sep 2019 22:52:14 -0700 Received: from pgsmsx106.gar.corp.intel.com (10.221.44.98) by PGSMSX112.gar.corp.intel.com (10.108.55.201) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 18 Sep 2019 13:51:15 +0800 Received: from pgsmsx111.gar.corp.intel.com ([169.254.2.128]) by PGSMSX106.gar.corp.intel.com ([169.254.9.23]) with mapi id 14.03.0439.000; Wed, 18 Sep 2019 13:51:15 +0800 From: "Chiu, Chasel" To: "Zhang, Shenglei" , "devel@edk2.groups.io" CC: "Kubacki, Michael A" , "Desimone, Nathaniel L" , "Gao, Liming" Subject: Re: [PATCH v3] MinPlatformPkg/TestPointCheckLib: Add check for pointers Thread-Topic: [PATCH v3] MinPlatformPkg/TestPointCheckLib: Add check for pointers Thread-Index: AQHVbcQAmFOSTR4S5E+n32ONRCmeo6cw7V+g Date: Wed, 18 Sep 2019 05:51:15 +0000 Message-ID: <3C3EFB470A303B4AB093197B6777CCEC504D219A@PGSMSX111.gar.corp.intel.com> References: <20190918015416.43684-1-shenglei.zhang@intel.com> In-Reply-To: <20190918015416.43684-1-shenglei.zhang@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.2.0.6 dlp-reaction: no-action x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiZWY4ZDE5YjktNjhlZS00M2I3LWFkY2MtZTU1YjI0ZjA2OTNmIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiY094WGVVTUk2dlwvMnd5UXlhU2t2aGl0blhqMzRPRmkzc2VHUUJqU09JbjFDXC9KXC95Z25qUjB6aSt6anlDNmtLQSJ9 x-ctpclassification: CTP_NT x-originating-ip: [172.30.20.205] MIME-Version: 1.0 Return-Path: chasel.chiu@intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Feedbacks in below inline. Thanks! Chasel > -----Original Message----- > From: Zhang, Shenglei > Sent: Wednesday, September 18, 2019 9:54 AM > To: devel@edk2.groups.io > Cc: Kubacki, Michael A ; Chiu, Chasel > ; Desimone, Nathaniel L > ; Gao, Liming > Subject: [PATCH v3] MinPlatformPkg/TestPointCheckLib: Add check for > pointers >=20 > In DxeCheckBootVariable.c, add check for BootOrder and Variable that > return EFI_NOT_FOUND when they are NULL. > In DxeCheckGcd.c, add check for GcdIoMap to ensure it not NULL when > allocating memory to what it points to. >=20 > Cc: Michael Kubacki > Cc: Chasel Chiu > Cc: Nate DeSimone > Cc: Liming Gao > Signed-off-by: Shenglei Zhang > --- >=20 > v2: Update copyright >=20 > v3: Fix the coding style. >=20 > .../Test/Library/TestPointCheckLib/DxeCheckBootVariable.c | 8 +++++++- > .../Test/Library/TestPointCheckLib/DxeCheckGcd.c | 8 +++++--- > 2 files changed, 12 insertions(+), 4 deletions(-) >=20 > diff --git > a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckB > ootVariable.c > b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckB > ootVariable.c > index 85bd5b3d..f658beb7 100644 > --- > a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckB > ootVariable.c > +++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCh > +++ eckBootVariable.c > @@ -1,6 +1,6 @@ > /** @file >=20 > -Copyright (c) 2017, Intel Corporation. All rights reserved.
> +Copyright (c) 2017-2019, Intel Corporation. All rights reserved.
> SPDX-License-Identifier: BSD-2-Clause-Patent >=20 > **/ > @@ -130,6 +130,9 @@ TestPointCheckLoadOptionVariable ( > for (ListIndex =3D 0; ListIndex < > sizeof(mLoadOptionVariableList)/sizeof(mLoadOptionVariableList[0]); > ListIndex++) { > UnicodeSPrint (BootOrderName, sizeof(BootOrderName), L"%sOrder", > mLoadOptionVariableList[ListIndex]); > Status =3D GetVariable2 (BootOrderName, &gEfiGlobalVariableGuid, > (VOID **)&BootOrder, &OrderSize); > + if(BootOrder =3D=3D NULL) { > + return EFI_NOT_FOUND; > + } I think we should continue the loop when BootOrder =3D=3D NULL, we should n= ot just return. Suggest to combine the condition check in following line: If (EFI_ERROR(Status) || (BootOrder =3D=3D NULL)) { continue; } > if (EFI_ERROR(Status)) { > continue; > } > @@ -222,6 +225,9 @@ TestPointCheckKeyOptionVariable ( > for (Index =3D 0; ; Index++) { > UnicodeSPrint (KeyOptionName, sizeof(KeyOptionName), L"%s%04x", > mKeyOptionVariableList[ListIndex], Index); > Status =3D GetVariable2 (KeyOptionName, &gEfiGlobalVariableGuid, > &Variable, &Size); > + if(Variable =3D=3D NULL) { > + return EFI_NOT_FOUND; > + } Same here, I think we should not return directly. Combine the check in following line: If (!EFI_ERROR(Status) && (Variable !=3D NULL)) { DumpKeyOption (...); else { ... > if (!EFI_ERROR(Status)) { > DumpKeyOption (KeyOptionName, Variable, Size); > } else { > diff --git > a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckG > cd.c > b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckG > cd.c > index 82709d44..28ca8382 100644 > --- > a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckG > cd.c > +++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCh > +++ eckGcd.c > @@ -1,6 +1,6 @@ > /** @file >=20 > -Copyright (c) 2017, Intel Corporation. All rights reserved.
> +Copyright (c) 2017-2019, Intel Corporation. All rights reserved.
> SPDX-License-Identifier: BSD-2-Clause-Patent >=20 > **/ > @@ -241,11 +241,13 @@ TestPointDumpGcd ( > } > } > if (GcdMemoryMap !=3D NULL) { > - *GcdIoMap =3D AllocateCopyPool (NumberOfDescriptors * > sizeof(EFI_GCD_IO_SPACE_DESCRIPTOR), IoMap); > + if (GcdIoMap !=3D NULL) { > + *GcdIoMap =3D AllocateCopyPool (NumberOfDescriptors * > sizeof(EFI_GCD_IO_SPACE_DESCRIPTOR), IoMap); > + } > *GcdIoMapNumberOfDescriptors =3D NumberOfDescriptors; > } > } > - > + > if (DumpPrint) { > DEBUG ((DEBUG_INFO, "=3D=3D=3D=3D TestPointDumpGcd - Exit\n")); > } > -- > 2.18.0.windows.1