From c466fbc0f08737edc034e55616c1e01210da1f2f Mon Sep 17 00:00:00 2001 From: Alex James Date: Sun, 5 Dec 2021 01:37:11 -0800 Subject: [PATCH] OcMemoryLib: Avoid rebuilding attributes when MAT is empty (#304) Some firmware implementations may provide an empty Memory Attributes Table (NumberOfEntries is zero). Avoid calling OcUpdateDescriptors in this case, as it will lead to division by zero. This resolves boot failures due to #DE on XPS 15 9560 when Secure Boot is enabled. --- Library/OcMemoryLib/MemoryAttributes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/OcMemoryLib/MemoryAttributes.c b/Library/OcMemoryLib/MemoryAttributes.c index e0f00646..4e2c7f08 100644 --- a/Library/OcMemoryLib/MemoryAttributes.c +++ b/Library/OcMemoryLib/MemoryAttributes.c @@ -438,7 +438,7 @@ OcRebuildAttributes ( UINT32 DescriptorVersion; MemoryAttributesTable = OcGetMemoryAttributes (&MemoryAttributesEntry); - if (MemoryAttributesTable == NULL) { + if (MemoryAttributesTable == NULL || MemoryAttributesTable->NumberOfEntries == 0) { return EFI_UNSUPPORTED; }