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 C261C1A1E28 for ; Thu, 27 Oct 2016 18:17:58 -0700 (PDT) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga102.jf.intel.com with ESMTP; 27 Oct 2016 18:17:58 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,406,1473145200"; d="scan'208";a="1060374216" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by fmsmga001.fm.intel.com with ESMTP; 27 Oct 2016 18:17:58 -0700 Received: from fmsmsx123.amr.corp.intel.com (10.18.125.38) 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:17:58 -0700 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by fmsmsx123.amr.corp.intel.com (10.18.125.38) with Microsoft SMTP Server (TLS) id 14.3.248.2; Thu, 27 Oct 2016 18:17:52 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.206]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.2]) with mapi id 14.03.0248.002; Fri, 28 Oct 2016 09:17:50 +0800 From: "Fu, Siyuan" To: "Zhang, Lubo" , "edk2-devel@lists.01.org" CC: "Wu, Jiaxin" Thread-Topic: [patch] NetworkPkg: Add error handling logic when using AllocateZeorPool Thread-Index: AQHSMCWWHBPk/Gt5OUWRYCR8sZ61HqC9EeGQ Date: Fri, 28 Oct 2016 01:17:50 +0000 Message-ID: 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-ctpclassification: CTP_IC x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMDdlNjY0NTctYTNmZi00NTFmLWEzMmUtMmUxNjJhYzEwZGI0IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjkuNi42IiwiVHJ1c3RlZExhYmVsSGFzaCI6IkxVTkdQb01NeURKbEJTMndwVzMzYzJYZnVEditrVDZZTWZaY1FWem1TY2M9In0= 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:17:58 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Fu Siyuan siyuan.fu@intel.com > -----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 > 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. >=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