From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) (using TLSv1 with cipher CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 2E3E21A1E28 for ; Thu, 27 Oct 2016 18:09:21 -0700 (PDT) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga102.jf.intel.com with ESMTP; 27 Oct 2016 18:09:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,406,1473145200"; d="scan'208";a="1076969468" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by fmsmga002.fm.intel.com with ESMTP; 27 Oct 2016 18:07:16 -0700 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.248.2; Thu, 27 Oct 2016 18:07:15 -0700 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.139]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.104]) with mapi id 14.03.0248.002; Fri, 28 Oct 2016 09:07:13 +0800 From: "Wu, Jiaxin" To: "Zhang, Lubo" , "edk2-devel@lists.01.org" CC: "Fu, Siyuan" Thread-Topic: [patch] NetworkPkg: Add error handling logic when using AllocateZeorPool Thread-Index: AQHSMCWWweD6Jxwq/E26VF3ZcyyOh6C9DsvA Date: Fri, 28 Oct 2016 01:07:12 +0000 Message-ID: <895558F6EA4E3B41AC93A00D163B72741389FDD0@SHSMSX103.ccr.corp.intel.com> References: <1477554088-28364-1-git-send-email-lubo.zhang@intel.com> In-Reply-To: <1477554088-28364-1-git-send-email-lubo.zhang@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMTY1YzFlYjQtYmFlNS00Y2EyLWJlMTQtM2UxYTg1YzBlYjcxIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjkuNi42IiwiVHJ1c3RlZExhYmVsSGFzaCI6IlBSVzYxK0w0Uitsc1dOWTZhdmt6NitVQmxZNjNjMEcxN1RZSFBvcXlJTHc9In0= x-ctpclassification: CTP_IC x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [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: Fri, 28 Oct 2016 01:09:21 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-By: Wu Jiaxin Best Regards! Jiaxin > -----Original Message----- > From: Zhang, Lubo > Sent: Thursday, October 27, 2016 3:41 PM > To: edk2-devel@lists.01.org > Cc: Fu, Siyuan ; Wu, Jiaxin > Subject: [patch] NetworkPkg: Add error handling logic when using > AllocateZeorPool >=20 > Add error handling logic if failed to apply new memory. >=20 > 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(-) >=20 > 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. >=20 > @param[in] Private The pointer to PXEBC_PRIVATE_DATA. >=20 > - @retval EFI_SUCCESS Handled the DHCPv6 offer packet succes= sfully. > - @retval EFI_NO_RESPONSE No response to the following request p= acket. > + @retval EFI_SUCCESS Handled the DHCPv6 offer packet succ= essfully. > + @retval EFI_NO_RESPONSE No response to the following request > packet. > + @retval EFI_OUT_OF_RESOURCES Failed to allocate resources. >=20 > **/ > 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] !=3D NULL) { > Private->DnsServer =3D AllocateZeroPool (NTOHS (Cache6- > >OptList[PXEBC_DHCP6_IDX_DNS_SERVER]->OpLen)); > + if (Private->DnsServer =3D=3D NULL) { > + return EFI_OUT_OF_RESOURCES; > + } > CopyMem (Private->DnsServer, Cache6- > >OptList[PXEBC_DHCP6_IDX_DNS_SERVER]->Data, sizeof (EFI_IPv6_ADDRESS)); > } >=20 > if (Cache6->OfferType =3D=3D PxeOfferTypeDhcpBinl) { > // > -- > 1.9.5.msysgit.1