From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.31; helo=mga06.intel.com; envelope-from=star.zeng@intel.com; receiver=edk2-devel@lists.01.org Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 9889E221DB297 for ; Fri, 29 Dec 2017 02:13:33 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 Dec 2017 02:18:30 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,475,1508828400"; d="scan'208";a="16379183" Received: from shwdeopenpsi068.ccr.corp.intel.com ([10.239.158.46]) by fmsmga004.fm.intel.com with ESMTP; 29 Dec 2017 02:18:29 -0800 From: Star Zeng To: edk2-devel@lists.01.org Cc: Star Zeng , Jian J Wang , Jiewen Yao Date: Fri, 29 Dec 2017 18:14:24 +0800 Message-Id: <1514542464-14676-1-git-send-email-star.zeng@intel.com> X-Mailer: git-send-email 2.7.0.windows.1 Subject: [PATCH] MdeModulePkg VarCheckHii: Make sure the bin at required alignment X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Dec 2017 10:13:34 -0000 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 --- MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGen.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGen.c b/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGen.c index c0efed450bfb..0db1383491f7 100644 --- a/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGen.c +++ b/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGen.c @@ -1518,6 +1518,10 @@ BuildVarCheckHiiBin ( // Data = AllocateRuntimeZeroPool (BinSize); ASSERT (Data != NULL); + // + // Make sure the allocated buffer for VarCheckHiiBin at required alignment. + // + ASSERT ((((UINTN) Data) & (HEADER_ALIGNMENT - 1)) == 0); DEBUG ((DEBUG_INFO, "VarCheckHiiBin - built at 0x%x\n", Data)); // -- 2.7.0.windows.1