From nobody Wed May 8 10:23:02 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 1513133008898767.8398512194838; Tue, 12 Dec 2017 18:43:28 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 7ACC72214E334; Tue, 12 Dec 2017 18:38:48 -0800 (PST) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) (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 C9AF82214E322 for ; Tue, 12 Dec 2017 18:38:46 -0800 (PST) Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Dec 2017 18:43:25 -0800 Received: from sfu5-mobl.ccr.corp.intel.com ([10.239.192.226]) by orsmga007.jf.intel.com with ESMTP; 12 Dec 2017 18:43:24 -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: Permerror (SPF Permanent Error: More than 10 MX records returned) identity=mailfrom; client-ip=192.55.52.151; helo=mga17.intel.com; envelope-from=siyuan.fu@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,396,1508828400"; d="scan'208";a="2273645" From: Fu Siyuan To: edk2-devel@lists.01.org Date: Wed, 13 Dec 2017 10:43:21 +0800 Message-Id: <20171213024321.9664-1-siyuan.fu@intel.com> X-Mailer: git-send-email 2.13.0.windows.1 Subject: [edk2] [Patch] MdeModulePkg/Ip4Dxe: return error on memory allocate failure instead of ASSERT. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ye Ting , Wang Fan , Wu Jiaxin 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" This patch updates the IP4 driver to use error status code instead of ASSERT if failed to allocate memory buffer. Cc: Ye Ting Cc: Wu Jiaxin Cc: Wang Fan Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Fu Siyuan Reviewed-by: Ye Ting =20 --- MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Nv.c | 19 +++++++++++++++-= --- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Nv.c b/MdeModu= lePkg/Universal/Network/Ip4Dxe/Ip4Config2Nv.c index c8dc6976d7..694a2d0e1f 100644 --- a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Nv.c +++ b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Nv.c @@ -293,8 +293,12 @@ Ip4Config2IpToStr ( @param[in] IpCount The size of IPv4 address list. @param[out] Str The string contains several decimal dotted IPv4 addresses separated by space. =20 + + @retval EFI_SUCCESS Operation is success. + @retval EFI_OUT_OF_RESOURCES Error occurs in allocating memory. + **/ -VOID +EFI_STATUS Ip4Config2IpListToStr ( IN EFI_IPv4_ADDRESS *Ip, IN UINTN IpCount, @@ -317,7 +321,9 @@ Ip4Config2IpListToStr ( TempIp =3D Ip + Index; if (TempStr =3D=3D NULL) { TempStr =3D AllocateZeroPool(2 * IP4_STR_MAX_SIZE); - ASSERT(TempStr !=3D NULL); + if (TempStr =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; + } } =20 UnicodeSPrint ( @@ -347,6 +353,8 @@ Ip4Config2IpListToStr ( if (TempStr !=3D NULL) { FreePool(TempStr); } + + return EFI_SUCCESS; } =20 /** @@ -518,7 +526,7 @@ Ip4Config2ConvertConfigNvDataToIfrNvData ( Ip4Config2IpToStr (&Ip4Info->StationAddress, IfrNvData->StationAddress); Ip4Config2IpToStr (&Ip4Info->SubnetMask, IfrNvData->SubnetMask); Ip4Config2IpToStr (&GatewayAddress, IfrNvData->GatewayAddress); - Ip4Config2IpListToStr (DnsAddress, DnsCount, IfrNvData->DnsAddress); + Status =3D Ip4Config2IpListToStr (DnsAddress, DnsCount, IfrNvData->DnsAd= dress); =20 Exit: =20 @@ -914,7 +922,10 @@ Ip4FormExtractConfig ( ConfigRequestHdr =3D HiiConstructConfigHdr (&gIp4Config2NvDataGuid, = mIp4Config2StorageName, Private->ChildHandle); Size =3D (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16); ConfigRequest =3D AllocateZeroPool (Size); - ASSERT (ConfigRequest !=3D NULL); + if (ConfigRequest =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + goto Failure; + } AllocatedRequest =3D TRUE; =20 UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=3D0&WIDTH=3D%016LX",= ConfigRequestHdr, (UINT64)BufferSize); --=20 2.13.0.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel