From: Star Zeng Date: Fri, 29 Dec 2017 10:12:36 +0000 (+0800) Subject: MdeModulePkg VarCheckPcd: Make sure the bin at required alignment X-Git-Tag: edk2-stable201903~2687 X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;ds=sidebyside;h=cd16355bbf3267f1ad7f678e91dc60cf31f3cb29;p=mirror_edk2.git MdeModulePkg VarCheckPcd: Make sure the bin at required alignment According to UEFI/PI spec, the AllocateXXXPool() interfaces should return eight-byte aligned buffer that satisfies the required HEADER_ALIGNMENT which is 4. This patch adds ASSERT to make sure the bin at required alignment, that can help catch the issue earlier about incorrect aligned buffer returned from AllocateXXXPool(). Cc: Jian J Wang Cc: Jiewen Yao Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Star Zeng Reviewed-by: Jian J Wang --- diff --git a/MdeModulePkg/Library/VarCheckPcdLib/VarCheckPcdLibNullClass.c b/MdeModulePkg/Library/VarCheckPcdLib/VarCheckPcdLibNullClass.c index 72b0363b19..d24ee966a4 100644 --- a/MdeModulePkg/Library/VarCheckPcdLib/VarCheckPcdLibNullClass.c +++ b/MdeModulePkg/Library/VarCheckPcdLib/VarCheckPcdLibNullClass.c @@ -1,7 +1,7 @@ /** @file Var Check PCD handler. -Copyright (c) 2015, Intel Corporation. All rights reserved.
+Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -435,6 +435,10 @@ LocateVarCheckPcdBin ( // mVarCheckPcdBin = AllocateRuntimeCopyPool (VarCheckPcdBinSize, VarCheckPcdBin); ASSERT (mVarCheckPcdBin != NULL); + // + // Make sure the allocated buffer for VarCheckPcdBin at required alignment. + // + ASSERT ((((UINTN) mVarCheckPcdBin) & (HEADER_ALIGNMENT - 1)) == 0); mVarCheckPcdBinSize = VarCheckPcdBinSize; FreePool (VarCheckPcdBin);