From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.65; helo=mga03.intel.com; envelope-from=fan.wang@intel.com; receiver=edk2-devel@lists.01.org Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (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 B18D32035D32C for ; Mon, 8 Jan 2018 17:14:05 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Jan 2018 17:19:15 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,333,1511856000"; d="scan'208";a="8181735" Received: from fanwang2-hp.ccr.corp.intel.com ([10.239.9.33]) by fmsmga007.fm.intel.com with ESMTP; 08 Jan 2018 17:19:14 -0800 From: Wang Fan To: edk2-devel@lists.01.org Cc: Jiaxin Wu , Ye Ting , Fu Siyuan Date: Tue, 9 Jan 2018 09:19:07 +0800 Message-Id: <1515460747-8372-3-git-send-email-fan.wang@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1515460747-8372-1-git-send-email-fan.wang@intel.com> References: <1515460747-8372-1-git-send-email-fan.wang@intel.com> Subject: [Patch 2/2] MdeModulePkg: Freed packet buffer when error occurs to avoid memory leak. 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: Tue, 09 Jan 2018 01:14:06 -0000 * In function Mtftp4WrqSendBlock(), when packet is not needed, function returns EFI_ABORTED but not freed the packet buffer. It results some memory leak and 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/Universal/Network/Mtftp4Dxe/Mtftp4Wrq.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Wrq.c b/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Wrq.c index e825714..438659a 100644 --- a/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Wrq.c +++ b/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Wrq.c @@ -1,9 +1,9 @@ /** @file Routines to process Wrq (upload). -Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php
@@ -92,10 +92,14 @@ Mtftp4WrqSendBlock ( if (EFI_ERROR (Status) || (DataLen > Instance->BlkSize)) { if (DataBuf != NULL) { FreePool (DataBuf); } + if (UdpPacket != NULL) { + NetbufFree (UdpPacket); + } + Mtftp4SendError ( Instance, EFI_MTFTP4_ERRORCODE_REQUEST_DENIED, (UINT8 *) "User aborted the transfer" ); -- 1.9.5.msysgit.1