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.136, mailfrom: ray.ni@intel.com) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by groups.io with SMTP; Mon, 26 Aug 2019 16:52:03 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Aug 2019 16:52:03 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,435,1559545200"; d="scan'208";a="180038321" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by fmsmga008.fm.intel.com with ESMTP; 26 Aug 2019 16:52:03 -0700 Received: from fmsmsx118.amr.corp.intel.com (10.18.116.18) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 26 Aug 2019 16:52:03 -0700 Received: from shsmsx154.ccr.corp.intel.com (10.239.6.54) by fmsmsx118.amr.corp.intel.com (10.18.116.18) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 26 Aug 2019 16:52:02 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.112]) by SHSMSX154.ccr.corp.intel.com ([169.254.7.249]) with mapi id 14.03.0439.000; Tue, 27 Aug 2019 07:52:00 +0800 From: "Ni, Ray" To: "Kubacki, Michael A" , "devel@edk2.groups.io" CC: "Chaganty, Rangasai V" Subject: Re: [edk2-platforms][PATCH V1 1/1] IntelSiliconPkg/IntelVTdDxe: Fix NULL pointer dereference Thread-Topic: [edk2-platforms][PATCH V1 1/1] IntelSiliconPkg/IntelVTdDxe: Fix NULL pointer dereference Thread-Index: AQHVWic8qBHwAwe5+ECDs1ddlZrcpacOHd2A Date: Mon, 26 Aug 2019 23:51:59 +0000 Message-ID: <734D49CCEBEEF84792F5B80ED585239D5C29CD54@SHSMSX104.ccr.corp.intel.com> References: <20190824025411.1192-1-michael.a.kubacki@intel.com> In-Reply-To: <20190824025411.1192-1-michael.a.kubacki@intel.com> Accept-Language: en-US, zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNTIwMWJhNmYtZTIzOS00MmRiLTllYWYtNDQ4ODM3YjZjN2MzIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiN2pYRDJJU3p5Yk1mUjdBQ284eDRjRnpkT3ErS0RQc3lNS1NFQkhxdFBySEUzRkpQSFNMQWdJN3ExUHlNR1dCbiJ9 x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.2.0.6 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Return-Path: ray.ni@intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Michael, > -----Original Message----- > From: Kubacki, Michael A > Sent: Friday, August 23, 2019 7:54 PM > To: devel@edk2.groups.io > Cc: Ni, Ray ; Chaganty, Rangasai V > Subject: [edk2-platforms][PATCH V1 1/1] IntelSiliconPkg/IntelVTdDxe: Fix = NULL pointer dereference >=20 > REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3D2116 >=20 > Cc: Ray Ni > Cc: Rangasai V Chaganty > Signed-off-by: Michael Kubacki > --- > Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/DmaProtection.c | = 19 +++++++++++-------- > 1 file changed, 11 insertions(+), 8 deletions(-) >=20 > diff --git a/Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/DmaPro= tection.c > b/Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/DmaProtection.c > index 956ebb2d3d..9b6135ef94 100644 > --- a/Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/DmaProtection= .c > +++ b/Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/DmaProtection= .c > @@ -158,10 +158,13 @@ ProcessRequestedAccessAttribute ( > } >=20 > /** > - return the UEFI memory information. > + Return UEFI memory map information. > + > + @param[out] Below4GMemoryLimit The below 4GiB memory limit address or= 0 if insufficient resources exist to > + determine the address. > + @param[out] Above4GMemoryLimit The above 4GiB memory limit address or= 0 if insufficient resources exist to > + determine the address. >=20 > - @param[out] Below4GMemoryLimit The below 4GiB memory limit > - @param[out] Above4GMemoryLimit The above 4GiB memory limit > **/ > VOID > ReturnUefiMemoryMap ( > @@ -206,7 +209,11 @@ ReturnUefiMemoryMap ( > // we process bogus entries and create bogus E820 entries. > // > EfiMemoryMap =3D (EFI_MEMORY_DESCRIPTOR *) AllocatePool (EfiMemoryMa= pSize); > - ASSERT (EfiMemoryMap !=3D NULL); > + if (EfiMemoryMap =3D=3D NULL) { > + ASSERT (EfiMemoryMap !=3D NULL); Above line may trigger a unreachable code error from some static code scann= er. How about move assertion to the line before if? > + return; > + } > + > Status =3D gBS->GetMemoryMap ( > &EfiMemoryMapSize, > EfiMemoryMap, > @@ -218,7 +225,6 @@ ReturnUefiMemoryMap ( > FreePool (EfiMemoryMap); > } > } while (Status =3D=3D EFI_BUFFER_TOO_SMALL); > - > ASSERT_EFI_ERROR (Status); >=20 > // > @@ -242,9 +248,6 @@ ReturnUefiMemoryMap ( > NextEfiEntry =3D NEXT_MEMORY_DESCRIPTOR (EfiEntry, EfiDescriptorSiz= e); > } >=20 > - // > - // > - // > DEBUG ((DEBUG_INFO, "MemoryMap:\n")); > EfiEntry =3D EfiMemoryMap; > EfiMemoryMapEnd =3D (EFI_MEMORY_DESCRIPTOR *) ((UINT8 *) EfiMemoryMap = + EfiMemoryMapSize); > -- > 2.16.2.windows.1