From ce22514e4800dca7854a4778a66e8f08d2b18345 Mon Sep 17 00:00:00 2001 From: Zhang Lubo Date: Thu, 28 Jan 2016 02:32:43 +0000 Subject: NetworkPkg:Fix Network memory leak when calling GetModeData interface Multiple network protocols have a GetModeData() interface, which may allocate memory resource in the return mode data structure. It's callers responsibility to free these buffers. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Zhang Lubo Reviewed-by: Fu Siyuan Reviewed-by: Wu Jiaxin git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@19758 6f19259b-4bc3-4df7-8a09-765794883524 --- NetworkPkg/Mtftp6Dxe/Mtftp6Support.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'NetworkPkg/Mtftp6Dxe') diff --git a/NetworkPkg/Mtftp6Dxe/Mtftp6Support.c b/NetworkPkg/Mtftp6Dxe/Mtftp6Support.c index c31fc9dc27..64df901d60 100644 --- a/NetworkPkg/Mtftp6Dxe/Mtftp6Support.c +++ b/NetworkPkg/Mtftp6Dxe/Mtftp6Support.c @@ -1,7 +1,7 @@ /** @file Mtftp6 support functions implementation. - Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.
+ Copyright (c) 2009 - 2016, 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 @@ -319,6 +319,29 @@ Mtftp6GetMapping ( Status = Udp6->GetModeData (Udp6, NULL, &Ip6Mode, NULL, NULL); if (!EFI_ERROR (Status)) { + if (Ip6Mode.AddressList != NULL) { + FreePool (Ip6Mode.AddressList); + } + + if (Ip6Mode.GroupTable != NULL) { + FreePool (Ip6Mode.GroupTable); + } + + if (Ip6Mode.RouteTable != NULL) { + FreePool (Ip6Mode.RouteTable); + } + + if (Ip6Mode.NeighborCache != NULL) { + FreePool (Ip6Mode.NeighborCache); + } + + if (Ip6Mode.PrefixTable != NULL) { + FreePool (Ip6Mode.PrefixTable); + } + + if (Ip6Mode.IcmpTypeList != NULL) { + FreePool (Ip6Mode.IcmpTypeList); + } if (Ip6Mode.IsConfigured) { // -- cgit v1.2.3