From cdda3f74a1327663a5d48cca13507085ba403af7 Mon Sep 17 00:00:00 2001 From: Marvin H?user Date: Mon, 9 Aug 2021 03:39:53 +0800 Subject: [PATCH] UefiPayloadPkg/UefiPayloadEntry: Fix memory corruption UefiPayloadEntry's AllocatePool() applies the "sizeof" operator to HOB index rather than the HOB header structure. This yields 4 Bytes compared to the 8 Bytes the structure header requires. Fix the call to allocate the required space instead. Reviewed-by: Guo Dong Reviewed-by: Ray Ni Cc: Maurice Ma Cc: Benjamin You Cc: Vitaly Cheptsov Signed-off-by: Marvin H?user --- UefiPayloadPkg/UefiPayloadEntry/MemoryAllocation.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UefiPayloadPkg/UefiPayloadEntry/MemoryAllocation.c b/UefiPayloadPkg/UefiPayloadEntry/MemoryAllocation.c index 1204573b3e..f3494969e5 100644 --- a/UefiPayloadPkg/UefiPayloadEntry/MemoryAllocation.c +++ b/UefiPayloadPkg/UefiPayloadEntry/MemoryAllocation.c @@ -163,7 +163,7 @@ AllocatePool ( return NULL; } - Hob = (EFI_HOB_MEMORY_POOL *)CreateHob (EFI_HOB_TYPE_MEMORY_POOL, (UINT16)(sizeof (EFI_HOB_TYPE_MEMORY_POOL) + AllocationSize)); + Hob = (EFI_HOB_MEMORY_POOL *)CreateHob (EFI_HOB_TYPE_MEMORY_POOL, (UINT16)(sizeof (EFI_HOB_MEMORY_POOL) + AllocationSize)); return (VOID *)(Hob + 1); }