From nobody Mon May 6 12:13:48 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1514542731572728.5091413400052; Fri, 29 Dec 2017 02:18:51 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id CC3AD22280C48; Fri, 29 Dec 2017 02:13:52 -0800 (PST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) (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 6D98D221DB297 for ; Fri, 29 Dec 2017 02:13:51 -0800 (PST) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 Dec 2017 02:18:47 -0800 Received: from shwdeopenpsi068.ccr.corp.intel.com ([10.239.158.46]) by fmsmga004.fm.intel.com with ESMTP; 29 Dec 2017 02:18:47 -0800 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.24; helo=mga09.intel.com; envelope-from=star.zeng@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,475,1508828400"; d="scan'208";a="16379254" From: Star Zeng To: edk2-devel@lists.01.org Date: Fri, 29 Dec 2017 18:18:46 +0800 Message-Id: <1514542726-12116-1-git-send-email-star.zeng@intel.com> X-Mailer: git-send-email 2.7.0.windows.1 Subject: [edk2] [PATCH] MdeModulePkg VarCheckPcd: 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: , Cc: Jiewen Yao , Star Zeng MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" 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 --- MdeModulePkg/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 72b0363b1979..d24ee966a44c 100644 --- a/MdeModulePkg/Library/VarCheckPcdLib/VarCheckPcdLibNullClass.c +++ b/MdeModulePkg/Library/VarCheckPcdLib/VarCheckPcdLibNullClass.c @@ -1,7 +1,7 @@ /** @file Var Check PCD handler. =20 -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 =3D AllocateRuntimeCopyPool (VarCheckPcdBinSize, VarCh= eckPcdBin); ASSERT (mVarCheckPcdBin !=3D NULL); + // + // Make sure the allocated buffer for VarCheckPcdBin at required align= ment. + // + ASSERT ((((UINTN) mVarCheckPcdBin) & (HEADER_ALIGNMENT - 1)) =3D=3D 0); mVarCheckPcdBinSize =3D VarCheckPcdBinSize; FreePool (VarCheckPcdBin); =20 --=20 2.7.0.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel