From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (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 1B3BC82142 for ; Mon, 19 Dec 2016 18:35:07 -0800 (PST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP; 19 Dec 2016 18:35:06 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,376,1477983600"; d="scan'208";a="1074243787" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by orsmga001.jf.intel.com with ESMTP; 19 Dec 2016 18:35:06 -0800 Received: from fmsmsx154.amr.corp.intel.com (10.18.116.70) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.248.2; Mon, 19 Dec 2016 18:35:06 -0800 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by FMSMSX154.amr.corp.intel.com (10.18.116.70) with Microsoft SMTP Server (TLS) id 14.3.248.2; Mon, 19 Dec 2016 18:35:05 -0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.54]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.159]) with mapi id 14.03.0248.002; Tue, 20 Dec 2016 10:35:04 +0800 From: "Yao, Jiewen" To: "Wu, Hao A" , "edk2-devel@lists.01.org" CC: "Fan, Jeff" , "Kinney, Michael D" Thread-Topic: [PATCH v2] UefiCpuPkg/PiSmmCpuDxeSmm: Add check to avoid NULL ptr dereference Thread-Index: AQHSWmfl5Z0ZKclMc0+ezIATyTtkpqEQHcQA Date: Tue, 20 Dec 2016 02:35:03 +0000 Message-ID: <74D8A39837DF1E4DA445A8C0B3885C503A8C6AFD@shsmsx102.ccr.corp.intel.com> References: <1482200536-11784-1-git-send-email-hao.a.wu@intel.com> In-Reply-To: <1482200536-11784-1-git-send-email-hao.a.wu@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 v2] UefiCpuPkg/PiSmmCpuDxeSmm: Add check to avoid NULL ptr dereference X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 20 Dec 2016 02:35:07 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Thanks. This function will be called in SMM exception handlers. The exception info = will be displayed later. There is no need to add debug message here. Please remove it. With that change, reviewed-by: Jiewen.yao@intel.com > -----Original Message----- > From: Wu, Hao A > Sent: Tuesday, December 20, 2016 10:22 AM > To: edk2-devel@lists.01.org > Cc: Wu, Hao A ; Yao, Jiewen ; F= an, > Jeff ; Kinney, Michael D > Subject: [PATCH v2] UefiCpuPkg/PiSmmCpuDxeSmm: Add check to avoid NULL > ptr dereference >=20 > Cc: Jiewen Yao > Cc: Jeff Fan > Cc: Michael Kinney > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Hao Wu > --- > UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c | 11 > +++++++++++ > 1 file changed, 11 insertions(+) >=20 > diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c > b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c > index f4716f3..d967255 100644 > --- a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c > +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c > @@ -1011,6 +1011,10 @@ GetUefiMemoryMap ( > } > } while (Status =3D=3D EFI_BUFFER_TOO_SMALL); >=20 > + if (MemoryMap =3D=3D NULL) { > + return ; > + } > + > SortMemoryMap (MemoryMap, UefiMemoryMapSize, mUefiDescriptorSize); > MergeMemoryMapForNotPresentEntry (MemoryMap, > &UefiMemoryMapSize, mUefiDescriptorSize); >=20 > @@ -1080,6 +1084,13 @@ IsSmmCommBufferForbiddenAddress ( > UINTN MemoryMapEntryCount; > UINTN Index; >=20 > + DEBUG ((DEBUG_INFO, "IsSmmCommBufferForbiddenAddress\n")); > + > + if (mUefiMemoryMap =3D=3D NULL) { > + DEBUG ((DEBUG_INFO, "UefiMemoryMap - NULL\n")); > + return FALSE; > + } > + > MemoryMap =3D mUefiMemoryMap; > MemoryMapEntryCount =3D mUefiMemoryMapSize/mUefiDescriptorSize; > for (Index =3D 0; Index < MemoryMapEntryCount; Index++) { > -- > 1.9.5.msysgit.0