This patch is to discard the normal ICMP packets and recycle the received
ICMP data to avoid the memory leak.

Cc: Siyuan Fu <[email protected]>
Cc: Heyi Guo <[email protected]>
Cc: Ye Ting <[email protected]>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jiaxin Wu <[email protected]>
Tested-by: Heyi Guo <[email protected]>
---
 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
[email protected]
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to