From cd16355bbf3267f1ad7f678e91dc60cf31f3cb29 Mon Sep 17 00:00:00 2001 From: Star Zeng Date: Fri, 29 Dec 2017 18:12:36 +0800 Subject: [PATCH] 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 --- .../Library/VarCheckPcdLib/VarCheckPcdLibNullClass.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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); -- 2.39.2