From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mx.groups.io with SMTP id smtpd.web12.4441.1583992953375121621 for ; Wed, 11 Mar 2020 23:02:33 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.20, mailfrom: shenglei.zhang@intel.com) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Mar 2020 23:02:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,543,1574150400"; d="scan'208";a="389498296" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by orsmga004.jf.intel.com with ESMTP; 11 Mar 2020 23:02:32 -0700 Received: from FMSMSX109.amr.corp.intel.com (10.18.116.9) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 11 Mar 2020 23:02:31 -0700 Received: from shsmsx103.ccr.corp.intel.com (10.239.4.69) by fmsmsx109.amr.corp.intel.com (10.18.116.9) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 11 Mar 2020 23:02:31 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.206]) by SHSMSX103.ccr.corp.intel.com ([169.254.4.137]) with mapi id 14.03.0439.000; Thu, 12 Mar 2020 14:02:28 +0800 From: "Zhang, Shenglei" To: "devel@edk2.groups.io" , "newexplorerj@gmail.com" CC: "Kinney, Michael D" , Sean Brogan , Bret Barkelew Subject: Re: [edk2-devel] [PATCH v2] UnitTestFrameworkPkg/UnitTestLib: Check Suite pointer before use. Thread-Topic: [edk2-devel] [PATCH v2] UnitTestFrameworkPkg/UnitTestLib: Check Suite pointer before use. Thread-Index: AQHV8rYF26RtF9KvSU2YOBa/mBXIPahEgiLA Date: Thu, 12 Mar 2020 06:02:28 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Return-Path: shenglei.zhang@intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Shenglei Zhang > -----Original Message----- > From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of > GuoMinJ > Sent: Thursday, March 5, 2020 2:18 PM > To: devel@edk2.groups.io > Cc: GuoMinJ ; Kinney, Michael D > ; Sean Brogan ; > Bret Barkelew > Subject: [edk2-devel] [PATCH v2] UnitTestFrameworkPkg/UnitTestLib: Check > Suite pointer before use. >=20 > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2530 >=20 > The Suite pointer is used before check if it is valid, > correct it to check the validation before use. >=20 > Cc: Michael D Kinney > Cc: Sean Brogan > Cc: Bret Barkelew > Signed-off-by: GuoMinJ > --- > UnitTestFrameworkPkg/Library/UnitTestLib/RunTests.c | 6 +++--- > UnitTestFrameworkPkg/Library/UnitTestLib/UnitTestLib.c | 2 +- > 2 files changed, 4 insertions(+), 4 deletions(-) >=20 > diff --git a/UnitTestFrameworkPkg/Library/UnitTestLib/RunTests.c > b/UnitTestFrameworkPkg/Library/UnitTestLib/RunTests.c > index fb247c59e7..b053e04959 100644 > --- a/UnitTestFrameworkPkg/Library/UnitTestLib/RunTests.c > +++ b/UnitTestFrameworkPkg/Library/UnitTestLib/RunTests.c > @@ -33,13 +33,13 @@ RunTestSuite ( > UNIT_TEST *Test; > UNIT_TEST_FRAMEWORK *ParentFramework; >=20 > - TestEntry =3D NULL; > - ParentFramework =3D (UNIT_TEST_FRAMEWORK *)Suite->ParentFramework; > - > if (Suite =3D=3D NULL) { > return EFI_INVALID_PARAMETER; > } >=20 > + TestEntry =3D NULL; > + ParentFramework =3D (UNIT_TEST_FRAMEWORK *)Suite- > >ParentFramework; > + > DEBUG ((DEBUG_VERBOSE, "---------------------------------------------= ----------- > -\n")); > DEBUG ((DEBUG_VERBOSE, "RUNNING TEST SUITE: %a\n", Suite->Title)); > DEBUG ((DEBUG_VERBOSE, "---------------------------------------------= ----------- > -\n")); > diff --git a/UnitTestFrameworkPkg/Library/UnitTestLib/UnitTestLib.c > b/UnitTestFrameworkPkg/Library/UnitTestLib/UnitTestLib.c > index fd15991ea4..b136992d99 100644 > --- a/UnitTestFrameworkPkg/Library/UnitTestLib/UnitTestLib.c > +++ b/UnitTestFrameworkPkg/Library/UnitTestLib/UnitTestLib.c > @@ -436,7 +436,6 @@ AddTestCase ( >=20 > Status =3D EFI_SUCCESS; > Suite =3D (UNIT_TEST_SUITE *)SuiteHandle; > - ParentFramework =3D (UNIT_TEST_FRAMEWORK *)Suite->ParentFramework; >=20 > // > // First, let's check to make sure that our parameters look good. > @@ -445,6 +444,7 @@ AddTestCase ( > return EFI_INVALID_PARAMETER; > } >=20 > + ParentFramework =3D (UNIT_TEST_FRAMEWORK *)Suite- > >ParentFramework; > // > // Create the new entry. > NewTestEntry =3D AllocateZeroPool (sizeof( UNIT_TEST_LIST_ENTRY )); > -- > 2.17.1 >=20 >=20 >=20