From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (using TLSv1 with cipher CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 086DE1A1DEF for ; Thu, 27 Oct 2016 00:41:36 -0700 (PDT) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP; 27 Oct 2016 00:41:36 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,404,1473145200"; d="scan'208";a="1050968672" Received: from shwdeopenpsi116.ccr.corp.intel.com ([10.239.9.20]) by orsmga001.jf.intel.com with ESMTP; 27 Oct 2016 00:41:34 -0700 From: Zhang Lubo To: edk2-devel@lists.01.org Cc: Fu Siyuan , Wu Jiaxin Date: Thu, 27 Oct 2016 15:41:28 +0800 Message-Id: <1477554088-28364-1-git-send-email-lubo.zhang@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.1 Subject: [patch] NetworkPkg: Add error handling logic when using AllocateZeorPool X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 27 Oct 2016 07:41:36 -0000 Add error handling logic if failed to apply new memory. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Zhang Lubo Cc: Fu Siyuan Cc: Wu Jiaxin --- NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c b/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c index 45377e3..eba8e1d 100644 --- a/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c +++ b/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c @@ -1296,12 +1296,13 @@ PxeBcSelectDhcp6Offer ( /** Handle the DHCPv6 offer packet. @param[in] Private The pointer to PXEBC_PRIVATE_DATA. - @retval EFI_SUCCESS Handled the DHCPv6 offer packet successfully. - @retval EFI_NO_RESPONSE No response to the following request packet. + @retval EFI_SUCCESS Handled the DHCPv6 offer packet successfully. + @retval EFI_NO_RESPONSE No response to the following request packet. + @retval EFI_OUT_OF_RESOURCES Failed to allocate resources. **/ EFI_STATUS PxeBcHandleDhcp6Offer ( IN PXEBC_PRIVATE_DATA *Private @@ -1323,10 +1324,13 @@ PxeBcHandleDhcp6Offer ( // // First try to cache DNS server address if DHCP6 offer provides. // if (Cache6->OptList[PXEBC_DHCP6_IDX_DNS_SERVER] != NULL) { Private->DnsServer = AllocateZeroPool (NTOHS (Cache6->OptList[PXEBC_DHCP6_IDX_DNS_SERVER]->OpLen)); + if (Private->DnsServer == NULL) { + return EFI_OUT_OF_RESOURCES; + } CopyMem (Private->DnsServer, Cache6->OptList[PXEBC_DHCP6_IDX_DNS_SERVER]->Data, sizeof (EFI_IPv6_ADDRESS)); } if (Cache6->OfferType == PxeOfferTypeDhcpBinl) { // -- 1.9.5.msysgit.1