From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (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 C95A121CF94F3 for ; Mon, 31 Jul 2017 21:55:17 -0700 (PDT) Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 31 Jul 2017 21:57:26 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.41,305,1498546800"; d="scan'208";a="114146559" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by orsmga004.jf.intel.com with ESMTP; 31 Jul 2017 21:57:26 -0700 Received: from fmsmsx153.amr.corp.intel.com (10.18.125.6) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 31 Jul 2017 21:56:49 -0700 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by FMSMSX153.amr.corp.intel.com (10.18.125.6) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 31 Jul 2017 21:56:48 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.146]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.134]) with mapi id 14.03.0319.002; Tue, 1 Aug 2017 12:56:45 +0800 From: "Yao, Jiewen" To: "Wu, Hao A" , "edk2-devel@lists.01.org" CC: "Wu, Hao A" Thread-Topic: [edk2] [PATCH 2/2] IntelSiliconPkg/IntelVTdDxe: Add explicit NULL pointer checks Thread-Index: AQHTCn8qwYtYtNaSaUWOQhzvVzWs5qJu8CLQ Date: Tue, 1 Aug 2017 04:56:45 +0000 Message-ID: <74D8A39837DF1E4DA445A8C0B3885C503A981568@shsmsx102.ccr.corp.intel.com> References: <20170801043203.23040-1-hao.a.wu@intel.com> <20170801043203.23040-3-hao.a.wu@intel.com> In-Reply-To: <20170801043203.23040-3-hao.a.wu@intel.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 10.0.102.7 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH 2/2] IntelSiliconPkg/IntelVTdDxe: Add explicit NULL pointer checks 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: Tue, 01 Aug 2017 04:55:17 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: jiewen.yao@intel.com > -----Original Message----- > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Ha= o > Wu > Sent: Tuesday, August 1, 2017 12:32 PM > To: edk2-devel@lists.01.org > Cc: Wu, Hao A ; Yao, Jiewen > Subject: [edk2] [PATCH 2/2] IntelSiliconPkg/IntelVTdDxe: Add explicit NUL= L > pointer checks >=20 > Add explicit NULL pointer check to make the codes more straight-forward. >=20 > Cc: Jiewen Yao > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Hao Wu > --- > IntelSiliconPkg/IntelVTdDxe/TranslationTable.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) >=20 > diff --git a/IntelSiliconPkg/IntelVTdDxe/TranslationTable.c > b/IntelSiliconPkg/IntelVTdDxe/TranslationTable.c > index 0cff2cc939..5af4a4627b 100644 > --- a/IntelSiliconPkg/IntelVTdDxe/TranslationTable.c > +++ b/IntelSiliconPkg/IntelVTdDxe/TranslationTable.c > @@ -862,6 +862,8 @@ SetAccessAttribute ( > VTD_SECOND_LEVEL_PAGING_ENTRY *SecondLevelPagingEntry; > UINT64 Pt; >=20 > + SecondLevelPagingEntry =3D NULL; > + > DEBUG ((DEBUG_INFO,"SetAccessAttribute (S%04x B%02x D%02x F%02x) > (0x%016lx - 0x%08x, %x)\n", Segment, SourceId.Bits.Bus, SourceId.Bits.Dev= ice, > SourceId.Bits.Function, BaseAddress, (UINTN)Length, IoMmuAccess)); >=20 > VtdIndex =3D FindVtdIndexByPciDevice (Segment, SourceId, &ExtContextEn= try, > &ContextEntry); > @@ -884,7 +886,7 @@ SetAccessAttribute ( > SecondLevelPagingEntry =3D (VOID *)(UINTN)LShiftU64 > (ExtContextEntry->Bits.SecondLevelPageTranslationPointer, 12); > DEBUG ((DEBUG_VERBOSE,"SecondLevelPagingEntry - 0x%x (S%04x > B%02x D%02x F%02x)\n", SecondLevelPagingEntry, Segment, SourceId.Bits.Bus= , > SourceId.Bits.Device, SourceId.Bits.Function)); > } > - } else { > + } else if (ContextEntry !=3D NULL) { > if (ContextEntry->Bits.Present =3D=3D 0) { > SecondLevelPagingEntry =3D CreateSecondLevelPagingEntry (VtdIndex,= 0); > DEBUG ((DEBUG_VERBOSE,"SecondLevelPagingEntry - 0x%x (S%04x > B%02x D%02x F%02x) New\n", SecondLevelPagingEntry, Segment, > SourceId.Bits.Bus, SourceId.Bits.Device, SourceId.Bits.Function)); > @@ -959,7 +961,7 @@ AlwaysEnablePageAttribute ( > ExtContextEntry->Bits.SecondLevelPageTranslationPointer =3D Pt; > ExtContextEntry->Bits.DomainIdentifier =3D ((1 << > (UINT8)((UINTN)mVtdUnitInformation[VtdIndex].CapReg.Bits.ND * 2 + 4)) - 1= ); > ExtContextEntry->Bits.Present =3D 1; > - } else { > + } else if (ContextEntry !=3D NULL) { > ContextEntry->Bits.SecondLevelPageTranslationPointer =3D Pt; > ContextEntry->Bits.DomainIdentifier =3D ((1 << > (UINT8)((UINTN)mVtdUnitInformation[VtdIndex].CapReg.Bits.ND * 2 + 4)) - 1= ); > ContextEntry->Bits.Present =3D 1; > -- > 2.12.0.windows.1 >=20 > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel