public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [patch] NetworkPkg: Add error handling logic when using AllocateZeorPool
@ 2016-10-27  7:41 Zhang Lubo
  2016-10-28  1:07 ` Wu, Jiaxin
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Zhang Lubo @ 2016-10-27  7:41 UTC (permalink / raw)
  To: edk2-devel; +Cc: Fu Siyuan, Wu Jiaxin

Add error handling logic if failed to apply new memory.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo <lubo.zhang@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Cc: Wu Jiaxin <jiaxin.wu@intel.com>
---
 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



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [patch] NetworkPkg: Add error handling logic when using AllocateZeorPool
  2016-10-27  7:41 [patch] NetworkPkg: Add error handling logic when using AllocateZeorPool Zhang Lubo
@ 2016-10-28  1:07 ` Wu, Jiaxin
  2016-10-28  1:17 ` Fu, Siyuan
  2016-10-28 10:46 ` Laszlo Ersek
  2 siblings, 0 replies; 4+ messages in thread
From: Wu, Jiaxin @ 2016-10-28  1:07 UTC (permalink / raw)
  To: Zhang, Lubo, edk2-devel@lists.01.org; +Cc: Fu, Siyuan

Reviewed-By: Wu Jiaxin <jiaxin.wu@intel.com>

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 <siyuan.fu@intel.com>; Wu, Jiaxin <jiaxin.wu@intel.com>
> Subject: [patch] NetworkPkg: Add error handling logic when using
> AllocateZeorPool
> 
> Add error handling logic if failed to apply new memory.
> 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Zhang Lubo <lubo.zhang@intel.com>
> Cc: Fu Siyuan <siyuan.fu@intel.com>
> Cc: Wu Jiaxin <jiaxin.wu@intel.com>
> ---
>  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



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch] NetworkPkg: Add error handling logic when using AllocateZeorPool
  2016-10-27  7:41 [patch] NetworkPkg: Add error handling logic when using AllocateZeorPool Zhang Lubo
  2016-10-28  1:07 ` Wu, Jiaxin
@ 2016-10-28  1:17 ` Fu, Siyuan
  2016-10-28 10:46 ` Laszlo Ersek
  2 siblings, 0 replies; 4+ messages in thread
From: Fu, Siyuan @ 2016-10-28  1:17 UTC (permalink / raw)
  To: Zhang, Lubo, edk2-devel@lists.01.org; +Cc: Wu, Jiaxin



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 <siyuan.fu@intel.com>; Wu, Jiaxin <jiaxin.wu@intel.com>
> Subject: [patch] NetworkPkg: Add error handling logic when using
> AllocateZeorPool
> 
> Add error handling logic if failed to apply new memory.
> 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Zhang Lubo <lubo.zhang@intel.com>
> Cc: Fu Siyuan <siyuan.fu@intel.com>
> Cc: Wu Jiaxin <jiaxin.wu@intel.com>
> ---
>  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



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch] NetworkPkg: Add error handling logic when using AllocateZeorPool
  2016-10-27  7:41 [patch] NetworkPkg: Add error handling logic when using AllocateZeorPool Zhang Lubo
  2016-10-28  1:07 ` Wu, Jiaxin
  2016-10-28  1:17 ` Fu, Siyuan
@ 2016-10-28 10:46 ` Laszlo Ersek
  2 siblings, 0 replies; 4+ messages in thread
From: Laszlo Ersek @ 2016-10-28 10:46 UTC (permalink / raw)
  To: Zhang Lubo; +Cc: edk2-devel, Fu Siyuan, Wu Jiaxin

On 10/27/16 09:41, Zhang Lubo wrote:
> Add error handling logic if failed to apply new memory.
> 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Zhang Lubo <lubo.zhang@intel.com>
> Cc: Fu Siyuan <siyuan.fu@intel.com>
> Cc: Wu Jiaxin <jiaxin.wu@intel.com>
> ---
>  NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)

Before you commit the patch, please fix the typo in the subject:
Zeor <-> Zero.

Thanks
Laszlo



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-10-28 10:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-27  7:41 [patch] NetworkPkg: Add error handling logic when using AllocateZeorPool Zhang Lubo
2016-10-28  1:07 ` Wu, Jiaxin
2016-10-28  1:17 ` Fu, Siyuan
2016-10-28 10:46 ` Laszlo Ersek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox