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.126; helo=mga18.intel.com; envelope-from=jian.j.wang@intel.com; receiver=edk2-devel@lists.01.org Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) (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 379E321168206 for ; Fri, 19 Oct 2018 01:12:26 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Oct 2018 01:12:26 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,399,1534834800"; d="scan'208";a="93291085" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by orsmga003.jf.intel.com with ESMTP; 19 Oct 2018 01:12:26 -0700 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.319.2; Fri, 19 Oct 2018 01:12:24 -0700 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.111]) by SHSMSX104.ccr.corp.intel.com ([169.254.5.183]) with mapi id 14.03.0319.002; Fri, 19 Oct 2018 16:12:02 +0800 From: "Wang, Jian J" To: "Zeng, Star" , "edk2-devel@lists.01.org" CC: "Gao, Liming" , "Kinney, Michael D" Thread-Topic: [PATCH] MdePkg UefiLib: Check Table against NULL in ScanTableInSDT Thread-Index: AQHUZ4K5+qsrwfdpOk2gFueuszjFfaUmN6oQ Date: Fri, 19 Oct 2018 08:12:01 +0000 Message-ID: References: <1539936417-78404-1-git-send-email-star.zeng@intel.com> In-Reply-To: <1539936417-78404-1-git-send-email-star.zeng@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiYWYyYTQ0ZWUtMjhjMC00Y2Y4LTg4N2EtZTkyNTE3NWRiNzk0IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiOUZpN1E1SW94eG10cUJWUHRUUHRoeUx2VHBLa2tuVytlaWNJNkw2emZGaXRnODIzOU9weTZjRkIzZTIxeG94SyJ9 x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.400.15 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH] MdePkg UefiLib: Check Table against NULL in ScanTableInSDT X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 19 Oct 2018 08:12:27 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Jian J Wang > -----Original Message----- > From: Zeng, Star > Sent: Friday, October 19, 2018 4:07 PM > To: edk2-devel@lists.01.org > Cc: Zeng, Star ; Gao, Liming ; > Kinney, Michael D ; Wang, Jian J > > Subject: [PATCH] MdePkg UefiLib: Check Table against NULL in ScanTableInS= DT >=20 > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1266 >=20 > af5e95215928e052445c473f1244412dadea8252 abstracted generic functions > from different modules (IntelVTdDxe, S3SaveStateDxe, PcRtc, > DpDynamicCommand and PiSmmCpuDxeSmm). Some of them (IntelVTdDxe and > PcRtc) checked Table against NULL before accessing Table->Signature, > some (S3SaveStateDxe, DpDynamicCommand and PiSmmCpuDxeSmm did not. >=20 > The ScanTableInSDT() in Acpi.c of UefiLib was mainly from > S3SaveStateDxe, so it does not check Table against NULL before > accessing Table->Signature. >=20 > This patch updates ScanTableInSDT() to check Table against NULL first > before accessing Table->Signature. >=20 > Cc: Liming Gao > Cc: Michael D Kinney > Cc: Jian J Wang > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Star Zeng > --- > MdePkg/Library/UefiLib/Acpi.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) >=20 > diff --git a/MdePkg/Library/UefiLib/Acpi.c b/MdePkg/Library/UefiLib/Acpi.= c > index 4df6731ff0a4..59a828835ca0 100644 > --- a/MdePkg/Library/UefiLib/Acpi.c > +++ b/MdePkg/Library/UefiLib/Acpi.c > @@ -67,7 +67,7 @@ ScanTableInSDT ( > EntryPtr =3D 0; > CopyMem (&EntryPtr, (VOID *)(BasePtr + Index * TablePointerSize), > TablePointerSize); > Table =3D (EFI_ACPI_COMMON_HEADER *)((UINTN)(EntryPtr)); > - if (Table->Signature =3D=3D Signature) { > + if ((Table !=3D NULL) && (Table->Signature =3D=3D Signature)) { > if (PreviousTable !=3D NULL) { > if (Table =3D=3D PreviousTable) { > *PreviousTableLocated =3D TRUE; > -- > 2.7.0.windows.1