[edk2] [Patch] MdeModulePkg/UefiPxeBcDxe: Discard the normal ICMP packets and recycle the received ICMP data.

Jiaxin Wu posted 1 patch 6 years, 4 months ago
Failed in applying to current master (apply log)
MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
[edk2] [Patch] MdeModulePkg/UefiPxeBcDxe: Discard the normal ICMP packets and recycle the received ICMP data.
Posted by Jiaxin Wu 6 years, 4 months ago
This patch is to discard the normal ICMP packets and recycle the received
ICMP data to avoid the memory leak.

Cc: Siyuan Fu <siyuan.fu@intel.com>
Cc: Heyi Guo <heyi.guo@linaro.org>
Cc: Ye Ting <ting.ye@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jiaxin Wu <jiaxin.wu@intel.com>
Tested-by: Heyi Guo <heyi.guo@linaro.org>
---
 MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.c b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.c
index 6d4f33f..4bfeaf3 100644
--- a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.c
+++ b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.c
@@ -164,17 +164,19 @@ IcmpErrorListenHandlerDpc (
     // The reception is actively aborted by the consumer, directly return.
     //
     return;
   }
 
-  if (EFI_ERROR (Status) || (RxData == NULL)) {
+  if (RxData == NULL) {
+    goto Resume;
+  }
+
+  if (Status != EFI_ICMP_ERROR) {
     //
-    // Only process the normal packets and the icmp error packets, if RxData is NULL
-    // with Status == EFI_SUCCESS or EFI_ICMP_ERROR, just resume the receive although
-    // this should be a bug of the low layer (IP).
+    // The return status should be recognized as EFI_ICMP_ERROR.
     //
-    goto Resume;
+    goto CleanUp;
   }
 
   if (EFI_IP4 (RxData->Header->SourceAddress) != 0 &&
       (NTOHL (Mode->SubnetMask.Addr[0]) != 0) &&
       IP4_NET_EQUAL (NTOHL(Mode->StationIp.Addr[0]), EFI_NTOHL (RxData->Header->SourceAddress), NTOHL (Mode->SubnetMask.Addr[0])) &&
@@ -214,12 +216,10 @@ IcmpErrorListenHandlerDpc (
         );
     }
     CopiedPointer += CopiedLen;
   }
 
-  goto Resume;
-
 CleanUp:
   gBS->SignalEvent (RxData->RecycleSignal);
 
 Resume:
   Ip4->Receive (Ip4, &(Private->IcmpErrorRcvToken));
-- 
1.9.5.msysgit.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
Re: [edk2] [Patch] MdeModulePkg/UefiPxeBcDxe: Discard the normal ICMP packets and recycle the received ICMP data.
Posted by Fu, Siyuan 6 years, 4 months ago

Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>



> -----Original Message-----
> From: Wu, Jiaxin
> Sent: Tuesday, December 12, 2017 7:27 PM
> To: edk2-devel@lists.01.org
> Cc: Fu, Siyuan <siyuan.fu@intel.com>; Heyi Guo <heyi.guo@linaro.org>; Ye,
> Ting <ting.ye@intel.com>
> Subject: [Patch] MdeModulePkg/UefiPxeBcDxe: Discard the normal ICMP
> packets and recycle the received ICMP data.
> 
> This patch is to discard the normal ICMP packets and recycle the received
> ICMP data to avoid the memory leak.
> 
> Cc: Siyuan Fu <siyuan.fu@intel.com>
> Cc: Heyi Guo <heyi.guo@linaro.org>
> Cc: Ye Ting <ting.ye@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Jiaxin Wu <jiaxin.wu@intel.com>
> Tested-by: Heyi Guo <heyi.guo@linaro.org>
> ---
>  MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.c | 14 +++++++-----
> --
>  1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.c
> b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.c
> index 6d4f33f..4bfeaf3 100644
> --- a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.c
> +++ b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.c
> @@ -164,17 +164,19 @@ IcmpErrorListenHandlerDpc (
>      // The reception is actively aborted by the consumer, directly return.
>      //
>      return;
>    }
> 
> -  if (EFI_ERROR (Status) || (RxData == NULL)) {
> +  if (RxData == NULL) {
> +    goto Resume;
> +  }
> +
> +  if (Status != EFI_ICMP_ERROR) {
>      //
> -    // Only process the normal packets and the icmp error packets, if
> RxData is NULL
> -    // with Status == EFI_SUCCESS or EFI_ICMP_ERROR, just resume the
> receive although
> -    // this should be a bug of the low layer (IP).
> +    // The return status should be recognized as EFI_ICMP_ERROR.
>      //
> -    goto Resume;
> +    goto CleanUp;
>    }
> 
>    if (EFI_IP4 (RxData->Header->SourceAddress) != 0 &&
>        (NTOHL (Mode->SubnetMask.Addr[0]) != 0) &&
>        IP4_NET_EQUAL (NTOHL(Mode->StationIp.Addr[0]), EFI_NTOHL (RxData-
> >Header->SourceAddress), NTOHL (Mode->SubnetMask.Addr[0])) &&
> @@ -214,12 +216,10 @@ IcmpErrorListenHandlerDpc (
>          );
>      }
>      CopiedPointer += CopiedLen;
>    }
> 
> -  goto Resume;
> -
>  CleanUp:
>    gBS->SignalEvent (RxData->RecycleSignal);
> 
>  Resume:
>    Ip4->Receive (Ip4, &(Private->IcmpErrorRcvToken));
> --
> 1.9.5.msysgit.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel