File ovmf-NetworkPkg-Fix-memory-leak-problem-in-PXE-driver.patch of Package ovmf.42234
From 2fad330f6baf350f80d043529f6a78ffec75daaa Mon Sep 17 00:00:00 2001
From: Fu Siyuan <siyuan.fu@intel.com>
Date: Tue, 2 Jan 2018 11:52:40 +0800
Subject: [PATCH] NetworkPkg: Fix memory leak problem in PXE driver.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Sriram Subramanian <sriram-s@hpe.com>
Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
---
NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c | 27 +++++++++++++++++++++------
NetworkPkg/UefiPxeBcDxe/PxeBcDriver.c | 5 ++++-
2 files changed, 25 insertions(+), 7 deletions(-)
Index: ovmf-2017+git1510945757.b2662641d5/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c
===================================================================
--- ovmf-2017+git1510945757.b2662641d5.orig/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c
+++ ovmf-2017+git1510945757.b2662641d5/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c
@@ -554,6 +554,7 @@ PxeBcExtractBootFileUrl (
if ((ModeStr != NULL) && (*(ModeStr + AsciiStrLen (";mode=octet")) == '\0')) {
*ModeStr = '\0';
} else if (AsciiStrStr (BootFileNamePtr, ";mode=") != NULL) {
+ FreePool (TmpStr);
return EFI_INVALID_PARAMETER;
}
@@ -1012,7 +1013,7 @@ PxeBcRequestBootService (
);
if (EFI_ERROR (Status)) {
- return Status;
+ goto ON_ERROR;
}
//
@@ -1027,7 +1028,7 @@ PxeBcRequestBootService (
//
Status = Private->Udp6Read->Configure (Private->Udp6Read, &Private->Udp6CfgData);
if (EFI_ERROR (Status)) {
- return Status;
+ goto ON_ERROR;
}
Status = PxeBc->UdpRead (
@@ -1048,7 +1049,7 @@ PxeBcRequestBootService (
Private->Udp6Read->Configure (Private->Udp6Read, NULL);
if (EFI_ERROR (Status)) {
- return Status;
+ goto ON_ERROR;
}
//
@@ -1057,6 +1058,13 @@ PxeBcRequestBootService (
Reply->Length = (UINT32)ReadSize;
return EFI_SUCCESS;
+
+ON_ERROR:
+ if (Discover != NULL) {
+ FreePool (Discover);
+ }
+
+ return Status;
}
/**
@@ -2238,7 +2246,7 @@ PxeBcDhcp6Discover (
(VOID *)Discover
);
if (EFI_ERROR (Status)) {
- return Status;
+ goto ON_ERROR;
}
//
@@ -2259,7 +2267,7 @@ PxeBcDhcp6Discover (
//
Status = Private->Udp6Read->Configure (Private->Udp6Read, &Private->Udp6CfgData);
if (EFI_ERROR (Status)) {
- return Status;
+ goto ON_ERROR;
}
Status = PxeBc->UdpRead (
@@ -2279,10 +2287,17 @@ PxeBcDhcp6Discover (
//
Private->Udp6Read->Configure (Private->Udp6Read, NULL);
if (EFI_ERROR (Status)) {
- return Status;
+ goto ON_ERROR;
}
return EFI_SUCCESS;
+
+ON_ERROR:
+ if (Discover != NULL) {
+ FreePool (Discover);
+ }
+
+ return Status;
}
/**
Index: ovmf-2017+git1510945757.b2662641d5/NetworkPkg/UefiPxeBcDxe/PxeBcDriver.c
===================================================================
--- ovmf-2017+git1510945757.b2662641d5.orig/NetworkPkg/UefiPxeBcDxe/PxeBcDriver.c
+++ ovmf-2017+git1510945757.b2662641d5/NetworkPkg/UefiPxeBcDxe/PxeBcDriver.c
@@ -2,7 +2,7 @@
Driver Binding functions implementationfor for UefiPxeBc Driver.
(C) Copyright 2014 Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
@@ -251,6 +251,7 @@ PxeBcDestroyIp4Children (
&Private->PxeBc,
NULL
);
+ FreePool (Private->Ip4Nic->DevicePath);
if (Private->Snp != NULL) {
//
@@ -411,6 +412,8 @@ PxeBcDestroyIp6Children (
&Private->PxeBc,
NULL
);
+ FreePool (Private->Ip6Nic->DevicePath);
+
if (Private->Snp != NULL) {
//
// Close SNP from the child virtual handle