From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.43; helo=mga05.intel.com; envelope-from=star.zeng@intel.com; receiver=edk2-devel@lists.01.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (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 B220A22225C17 for ; Tue, 26 Dec 2017 01:01:48 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Dec 2017 01:06:42 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,459,1508828400"; d="scan'208";a="4905953" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by fmsmga002.fm.intel.com with ESMTP; 26 Dec 2017 01:06:42 -0800 Received: from fmsmsx125.amr.corp.intel.com (10.18.125.40) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 26 Dec 2017 01:06:42 -0800 Received: from shsmsx103.ccr.corp.intel.com (10.239.4.69) by FMSMSX125.amr.corp.intel.com (10.18.125.40) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 26 Dec 2017 01:06:41 -0800 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.152]) by SHSMSX103.ccr.corp.intel.com ([169.254.4.213]) with mapi id 14.03.0319.002; Tue, 26 Dec 2017 17:06:40 +0800 From: "Zeng, Star" To: "Gao, Liming" , "edk2-devel@lists.01.org" CC: "Bi, Dandan" , "Zeng, Star" Thread-Topic: [Patch] MdeModulePkg HiiDataBaseDxe: Add the check for the memory allocation return Thread-Index: AQHTfiSjgNSAWB3q60iUXVsO6jj8QqNVVUIw Date: Tue, 26 Dec 2017 09:06:39 +0000 Message-ID: <0C09AFA07DD0434D9E2A0C6AEB0483103B9DD920@SHSMSX104.ccr.corp.intel.com> References: <1514277371-11760-1-git-send-email-liming.gao@intel.com> In-Reply-To: <1514277371-11760-1-git-send-email-liming.gao@intel.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [Patch] MdeModulePkg HiiDataBaseDxe: Add the check for the memory allocation return 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: Tue, 26 Dec 2017 09:01:49 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Star Zeng Thanks, Star -----Original Message----- From: Gao, Liming=20 Sent: Tuesday, December 26, 2017 4:36 PM To: edk2-devel@lists.01.org Cc: Zeng, Star Subject: [Patch] MdeModulePkg HiiDataBaseDxe: Add the check for the memory = allocation return Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Liming Gao Cc: Star Zeng --- MdeModulePkg/Universal/HiiDatabaseDxe/Database.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c b/MdeModulePk= g/Universal/HiiDatabaseDxe/Database.c index 7441c19..c10134b 100644 --- a/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c +++ b/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c @@ -844,6 +844,9 @@ UpdateDefaultSettingInFormPackage ( // Reallocate EFI VarStore Buffer // EfiVarStoreList =3D ReallocatePool (EfiVarStoreMaxNum * sizeof (= UINTN), (EfiVarStoreMaxNum + BASE_NUMBER) * sizeof (UINTN), EfiVarStoreList= ); + if (EfiVarStoreList =3D=3D NULL) { + break; + } EfiVarStoreMaxNum =3D EfiVarStoreMaxNum + BASE_NUMBER; } IfrEfiVarStore =3D (EFI_IFR_VARSTORE_EFI *) IfrOpHdr; @@ -851,6 +854= ,9 @@ UpdateDefaultSettingInFormPackage ( // Convert VarStore Name from ASCII string to Unicode string. // EfiVarStoreList [EfiVarStoreNumber] =3D AllocatePool (IfrEfiVarStore= ->Header.Length + AsciiStrSize ((CHAR8 *)IfrEfiVarStore->Name)); + if (EfiVarStoreList [EfiVarStoreNumber] =3D=3D NULL) { + break; + } CopyMem (EfiVarStoreList [EfiVarStoreNumber], IfrEfiVarStore, IfrEfi= VarStore->Header.Length); AsciiStrToUnicodeStrS ((CHAR8 *)IfrEfiVarStore->Name, (CHAR16 *) &(E= fiVarStoreList [EfiVarStoreNumber]->Name[0]), AsciiStrSize ((CHAR8 *)IfrEfi= VarStore->Name) * sizeof (CHAR16)); Status =3D FindQuestionDefaultSetting (EFI_HII_DEFAULT_CLASS_STANDAR= D, EfiVarStoreList[EfiVarStoreNumber], &VarStoreQuestionHeader, NULL, IfrEf= iVarStore->Size, FALSE); @@ -867,6 +873,9 @@ UpdateDefaultSettingInFormPack= age ( // Reallocate DefaultIdNumber // DefaultIdList =3D ReallocatePool (DefaultIdMaxNum * sizeof (UINT= 16), (DefaultIdMaxNum + BASE_NUMBER) * sizeof (UINT16), DefaultIdList); + if (DefaultIdList =3D=3D NULL) { + break; + } DefaultIdMaxNum =3D DefaultIdMaxNum + BASE_NUMBER; } DefaultIdList[DefaultIdNumber ++] =3D ((EFI_IFR_DEFAULTSTORE *) IfrO= pHdr)->DefaultId; -- 2.8.0.windows.1