From e7ac09b957561ba4533cb0a8297a568723ca8bd7 Mon Sep 17 00:00:00 2001 From: Star Zeng Date: Fri, 19 Oct 2018 15:56:57 +0800 Subject: MdePkg UefiLib: Check Table against NULL in ScanTableInSDT 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 Reviewed-by: Liming Gao Reviewed-by: Jian J Wang --- 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 4df6731ff0..59a828835c 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; -- cgit v1.2.3