From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.43; helo=mga05.intel.com; envelope-from=fan.wang@intel.com; receiver=edk2-devel@lists.01.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id C8824222EDCE2 for ; Tue, 9 Jan 2018 19:11:20 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Jan 2018 19:16:32 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,337,1511856000"; d="scan'208";a="8879736" Received: from fanwang2-hp.ccr.corp.intel.com ([10.239.9.33]) by fmsmga002.fm.intel.com with ESMTP; 09 Jan 2018 19:16:30 -0800 From: Wang Fan To: edk2-devel@lists.01.org Cc: Jiaxin Wu , Ye Ting , Fu Siyuan Date: Wed, 10 Jan 2018 11:16:27 +0800 Message-Id: <1515554188-2560-2-git-send-email-fan.wang@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1515554188-2560-1-git-send-email-fan.wang@intel.com> References: <1515554188-2560-1-git-send-email-fan.wang@intel.com> Subject: [Patch 1/2] MdeModulePkg: Freed the received packet buffer if it is not expected. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Jan 2018 03:11:21 -0000 * 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 --- 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 a06c0b6..c7bc1aa 100644 --- a/MdeModulePkg/Library/DxeIpIoLib/DxeIpIoLib.c +++ b/MdeModulePkg/Library/DxeIpIoLib/DxeIpIoLib.c @@ -1037,16 +1037,26 @@ IpIoListenHandlerDpc ( // The reception is actively aborted by the consumer, directly return. // 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; } if (NULL == IpIo->PktRcvdNotify) { goto CleanUp; -- 1.9.5.msysgit.1