From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.20; helo=mga02.intel.com; envelope-from=hao.a.wu@intel.com; receiver=edk2-devel@lists.01.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (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 E41D62095B093 for ; Sun, 8 Oct 2017 20:35:54 -0700 (PDT) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Oct 2017 20:39:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,498,1500966000"; d="scan'208";a="144240694" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by orsmga002.jf.intel.com with ESMTP; 08 Oct 2017 20:39:20 -0700 Received: from fmsmsx153.amr.corp.intel.com (10.18.125.6) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.319.2; Sun, 8 Oct 2017 20:39:20 -0700 Received: from shsmsx102.ccr.corp.intel.com (10.239.4.154) by FMSMSX153.amr.corp.intel.com (10.18.125.6) with Microsoft SMTP Server (TLS) id 14.3.319.2; Sun, 8 Oct 2017 20:39:20 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.152]) by shsmsx102.ccr.corp.intel.com ([169.254.2.175]) with mapi id 14.03.0319.002; Mon, 9 Oct 2017 11:39:18 +0800 From: "Wu, Hao A" To: "Dong, Eric" , "edk2-devel@lists.01.org" CC: "Ni, Ruiyu" Thread-Topic: [edk2] [Patch] UefiCpuPkg/PiSmmCpuDxeSmm: Add check to void use null pointer. Thread-Index: AQHTQK1PISlboBuz7kKVHsASfsfih6La3jYw Date: Mon, 9 Oct 2017 03:39:17 +0000 Message-ID: References: <1507519098-14284-1-git-send-email-eric.dong@intel.com> In-Reply-To: <1507519098-14284-1-git-send-email-eric.dong@intel.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [Patch] UefiCpuPkg/PiSmmCpuDxeSmm: Add check to void use null pointer. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Oct 2017 03:35:55 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable > -----Original Message----- > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Er= ic > Dong > Sent: Monday, October 09, 2017 11:18 AM > To: edk2-devel@lists.01.org > Cc: Ni, Ruiyu > Subject: [edk2] [Patch] UefiCpuPkg/PiSmmCpuDxeSmm: Add check to void use > null pointer. >=20 > Current code logic not check the pointer before use it. This may > has potential issue, this patch add code to check it. >=20 > Cc: Ruiyu Ni > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Eric Dong > --- > UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c | 5 +++++ > 1 file changed, 5 insertions(+) >=20 > diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c > b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c > index ef72b9b..2c1dc82 100644 > --- a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c > +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c > @@ -226,12 +226,17 @@ SetProcessorRegister ( > CPU_REGISTER_TABLE *RegisterTable; >=20 > InitApicId =3D GetInitialApicId (); > + RegisterTable =3D NULL; > for (Index =3D 0; Index < RegisterTableCount; Index++) { > if (RegisterTables[Index].InitialApicId =3D=3D InitApicId) { > RegisterTable =3D &RegisterTables[Index]; > break; > } > } > + ASSERT (RegisterTable !=3D NULL); > + if (RegisterTable =3D=3D NULL) { > + return; > + } Hi Eric, If "RegisterTable =3D=3D NULL" is a case that should never occur, my though= t is that using "ASSERT" merely is enough. The 'if' statement above seems can be removed for me. Best Regards, Hao Wu >=20 > // > // Traverse Register Table of this logical processor > -- > 2.7.0.windows.1 >=20 > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel