diff options
author | Star Zeng <star.zeng@intel.com> | 2017-12-29 18:12:36 +0800 |
---|---|---|
committer | Star Zeng <star.zeng@intel.com> | 2018-01-02 09:55:44 +0800 |
commit | cd16355bbf3267f1ad7f678e91dc60cf31f3cb29 (patch) | |
tree | 59c1d11584135eac7b74d2303104c08b444d062e /MdeModulePkg/Library | |
parent | 3d110afbcab02bab667a2179380626d8b5371903 (diff) | |
download | edk2-cd16355bbf3267f1ad7f678e91dc60cf31f3cb29.zip edk2-cd16355bbf3267f1ad7f678e91dc60cf31f3cb29.tar.gz edk2-cd16355bbf3267f1ad7f678e91dc60cf31f3cb29.tar.bz2 |
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 <jian.j.wang@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Jian J Wang <jian.j.wang@intel.com>
Diffstat (limited to 'MdeModulePkg/Library')
-rw-r--r-- | MdeModulePkg/Library/VarCheckPcdLib/VarCheckPcdLibNullClass.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/MdeModulePkg/Library/VarCheckPcdLib/VarCheckPcdLibNullClass.c b/MdeModulePkg/Library/VarCheckPcdLib/VarCheckPcdLibNullClass.c index 72b0363..d24ee96 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.<BR>
+Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.<BR>
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);
|