From 36c19ee6c7c4455f5de2817052444d1a0dad0e3d Mon Sep 17 00:00:00 2001 From: Wang Fan Date: Mon, 8 Jan 2018 13:18:26 +0800 Subject: [PATCH] MdeModulePkg: Freed packet buffer when error occurs to avoid memory leak. * 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 Reviewed-by: Fu Siyuan Reviewed-by: Jiaxin Wu --- 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 e825714700..438659a76e 100644 --- a/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Wrq.c +++ b/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Wrq.c @@ -1,7 +1,7 @@ /** @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 @@ -94,6 +94,10 @@ Mtftp4WrqSendBlock ( FreePool (DataBuf); } + if (UdpPacket != NULL) { + NetbufFree (UdpPacket); + } + Mtftp4SendError ( Instance, EFI_MTFTP4_ERRORCODE_REQUEST_DENIED,