From 0a1bd0a35dece044bee3b1ff580b58a3eeae7a4a Mon Sep 17 00:00:00 2001 From: Wang Fan Date: Wed, 10 Jan 2018 11:01:02 +0800 Subject: [PATCH] MdeModulePkg: Freed the received packet buffer if it is not expected. * When the packet is not normal packet or icmp error packet, the code does not recycle it by signal RecycleSignal event, and this will result some memory leak. This patch is to fix this issue. Cc: Jiaxin Wu Cc: Ye Ting Cc: Fu Siyuan Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Wang Fan Reviewed-by: Jiaxin Wu Reviewed-by: Fu Siyuan --- MdeModulePkg/Library/DxeIpIoLib/DxeIpIoLib.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/MdeModulePkg/Library/DxeIpIoLib/DxeIpIoLib.c b/MdeModulePkg/Library/DxeIpIoLib/DxeIpIoLib.c index a06c0b6a47..c7bc1aa8d0 100644 --- a/MdeModulePkg/Library/DxeIpIoLib/DxeIpIoLib.c +++ b/MdeModulePkg/Library/DxeIpIoLib/DxeIpIoLib.c @@ -1039,12 +1039,22 @@ IpIoListenHandlerDpc ( return; } - if (((EFI_SUCCESS != Status) && (EFI_ICMP_ERROR != Status)) || (NULL == RxData)) { + if ((EFI_SUCCESS != Status) && (EFI_ICMP_ERROR != Status)) { // - // @bug Only process the normal packets and the icmp error packets, if RxData is NULL - // @bug with Status == EFI_SUCCESS or EFI_ICMP_ERROR, just resume the receive although - // @bug this should be a bug of the low layer (IP). + // Only process the normal packets and the icmp error packets. // + if (RxData != NULL) { + goto CleanUp; + } else { + goto Resume; + } + } + + // + // if RxData is NULL with Status == EFI_SUCCESS or EFI_ICMP_ERROR, this should be a code issue in the low layer (IP). + // + ASSERT (RxData != NULL); + if (RxData == NULL) { goto Resume; }