From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.115; helo=mga14.intel.com; envelope-from=star.zeng@intel.com; receiver=edk2-devel@lists.01.org Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) (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 42FF621168207 for ; Fri, 19 Oct 2018 01:07:02 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Oct 2018 01:07:01 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,399,1534834800"; d="scan'208";a="272653085" Received: from shwdeopenpsi068.ccr.corp.intel.com ([10.239.158.46]) by fmsmga005.fm.intel.com with ESMTP; 19 Oct 2018 01:07:00 -0700 From: Star Zeng To: edk2-devel@lists.01.org Cc: Star Zeng , Liming Gao , Michael D Kinney , Jian J Wang Date: Fri, 19 Oct 2018 16:06:57 +0800 Message-Id: <1539936417-78404-1-git-send-email-star.zeng@intel.com> X-Mailer: git-send-email 2.7.0.windows.1 Subject: [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:07:02 -0000 REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1266 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. The ScanTableInSDT() in Acpi.c of UefiLib was mainly from S3SaveStateDxe, so it does not check Table against NULL before accessing Table->Signature. This patch updates ScanTableInSDT() to check Table against NULL first before accessing Table->Signature. 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(-) 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 = 0; CopyMem (&EntryPtr, (VOID *)(BasePtr + Index * TablePointerSize), TablePointerSize); Table = (EFI_ACPI_COMMON_HEADER *)((UINTN)(EntryPtr)); - if (Table->Signature == Signature) { + if ((Table != NULL) && (Table->Signature == Signature)) { if (PreviousTable != NULL) { if (Table == PreviousTable) { *PreviousTableLocated = TRUE; -- 2.7.0.windows.1