From: Fu Siyuan <siyuan.fu@intel.com>
To: edk2-devel@lists.01.org
Cc: Ye Ting <ting.ye@intel.com>, Wu Jiaxin <jiaxin.wu@intel.com>,
Wang Fan <fan.wang@intel.com>
Subject: [Patch 3/5] NetworkPkg: Fix memory leak problem in PXE driver.
Date: Tue, 2 Jan 2018 13:27:42 +0800 [thread overview]
Message-ID: <20180102052744.9928-4-siyuan.fu@intel.com> (raw)
In-Reply-To: <20180102052744.9928-1-siyuan.fu@intel.com>
Cc: Ye Ting <ting.ye@intel.com>
Cc: Wu Jiaxin <jiaxin.wu@intel.com>
Cc: Wang Fan <fan.wang@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Fu Siyuan <siyuan.fu@intel.com>
---
NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c | 27 +++++++++++++++++++++------
NetworkPkg/UefiPxeBcDxe/PxeBcDriver.c | 5 ++++-
2 files changed, 25 insertions(+), 7 deletions(-)
diff --git a/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c b/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c
index 327b4cf1cf..7c2baa8eac 100644
--- a/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c
+++ b/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c
@@ -548,6 +548,7 @@ PxeBcExtractBootFileUrl (
if (ModeStr != NULL && *(ModeStr + AsciiStrLen (";mode=octet")) == '\0') {
*ModeStr = '\0';
} else if (AsciiStrStr (BootFileNamePtr, ";mode=") != NULL) {
+ FreePool (TmpStr);
return EFI_INVALID_PARAMETER;
}
@@ -1005,7 +1006,7 @@ PxeBcRequestBootService (
);
if (EFI_ERROR (Status)) {
- return Status;
+ goto ON_ERROR;
}
//
@@ -1020,7 +1021,7 @@ PxeBcRequestBootService (
//
Status = Private->Udp6Read->Configure (Private->Udp6Read, &Private->Udp6CfgData);
if (EFI_ERROR (Status)) {
- return Status;
+ goto ON_ERROR;
}
Status = PxeBc->UdpRead (
@@ -1041,7 +1042,7 @@ PxeBcRequestBootService (
Private->Udp6Read->Configure (Private->Udp6Read, NULL);
if (EFI_ERROR (Status)) {
- return Status;
+ goto ON_ERROR;
}
//
@@ -1050,6 +1051,13 @@ PxeBcRequestBootService (
Reply->Length = (UINT32) ReadSize;
return EFI_SUCCESS;
+
+ON_ERROR:
+ if (Discover != NULL) {
+ FreePool (Discover);
+ }
+
+ return Status;
}
@@ -2158,7 +2166,7 @@ PxeBcDhcp6Discover (
(VOID *) Discover
);
if (EFI_ERROR (Status)) {
- return Status;
+ goto ON_ERROR;
}
//
@@ -2178,7 +2186,7 @@ PxeBcDhcp6Discover (
//
Status = Private->Udp6Read->Configure (Private->Udp6Read, &Private->Udp6CfgData);
if (EFI_ERROR (Status)) {
- return Status;
+ goto ON_ERROR;
}
Status = PxeBc->UdpRead (
@@ -2198,10 +2206,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;
}
diff --git a/NetworkPkg/UefiPxeBcDxe/PxeBcDriver.c b/NetworkPkg/UefiPxeBcDxe/PxeBcDriver.c
index 09c5753ad9..8dd787be1a 100644
--- a/NetworkPkg/UefiPxeBcDxe/PxeBcDriver.c
+++ b/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
@@ -254,6 +254,7 @@ PxeBcDestroyIp4Children (
&Private->PxeBc,
NULL
);
+ FreePool (Private->Ip4Nic->DevicePath);
if (Private->Snp != NULL) {
//
@@ -414,6 +415,8 @@ PxeBcDestroyIp6Children (
&Private->PxeBc,
NULL
);
+ FreePool (Private->Ip6Nic->DevicePath);
+
if (Private->Snp != NULL) {
//
// Close SNP from the child virtual handle
--
2.13.0.windows.1
next prev parent reply other threads:[~2018-01-02 5:22 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-02 5:27 [Patch 0/5] Refine PXE driver code logic Fu Siyuan
2018-01-02 5:27 ` [Patch 1/5] NetworkPkg: Abort the PXE process if DHCP has been started by other instance Fu Siyuan
2018-01-02 5:27 ` [Patch 2/5] NetworkPkg: Check allocated buffer pointer before use Fu Siyuan
2018-01-02 6:26 ` Gary Lin
2018-01-02 5:27 ` Fu Siyuan [this message]
2018-01-02 5:27 ` [Patch 4/5] NetworkPkg: Add assert for buffer pointer from DHCP driver Fu Siyuan
2018-01-02 5:27 ` [Patch 5/5] NetworkPkg: Update PXE driver to check for NULL pointer before use it Fu Siyuan
2018-01-02 5:43 ` Subramanian, Sriram
2018-01-02 5:45 ` [Patch 0/5] Refine PXE driver code logic Subramanian, Sriram
2018-01-02 5:50 ` Subramanian, Sriram
2018-01-04 1:02 ` Fu, Siyuan
2018-01-02 6:59 ` Wu, Jiaxin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180102052744.9928-4-siyuan.fu@intel.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox