]> git.proxmox.com Git - mirror_edk2.git/commitdiff
NetworkPkg: Fix memory leak problem in PXE driver.
authorFu Siyuan <siyuan.fu@intel.com>
Tue, 2 Jan 2018 03:52:40 +0000 (11:52 +0800)
committerFu Siyuan <siyuan.fu@intel.com>
Thu, 4 Jan 2018 01:07:32 +0000 (09:07 +0800)
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
NetworkPkg/UefiPxeBcDxe/PxeBcDriver.c

index 327b4cf1cfc5fc0f3e1ef388d51e05e188871756..7c2baa8eac01c995742e0a34ab736ef1884971a3 100644 (file)
@@ -548,6 +548,7 @@ PxeBcExtractBootFileUrl (
     if (ModeStr != NULL && *(ModeStr + AsciiStrLen (";mode=octet")) == '\0') {\r
       *ModeStr = '\0';\r
     } else if (AsciiStrStr (BootFileNamePtr, ";mode=") != NULL) {\r
     if (ModeStr != NULL && *(ModeStr + AsciiStrLen (";mode=octet")) == '\0') {\r
       *ModeStr = '\0';\r
     } else if (AsciiStrStr (BootFileNamePtr, ";mode=") != NULL) {\r
+      FreePool (TmpStr);\r
       return EFI_INVALID_PARAMETER;\r
     }\r
 \r
       return EFI_INVALID_PARAMETER;\r
     }\r
 \r
@@ -1005,7 +1006,7 @@ PxeBcRequestBootService (
                     );\r
 \r
   if (EFI_ERROR (Status)) {\r
                     );\r
 \r
   if (EFI_ERROR (Status)) {\r
-    return Status;\r
+    goto ON_ERROR;\r
   }\r
 \r
   //\r
   }\r
 \r
   //\r
@@ -1020,7 +1021,7 @@ PxeBcRequestBootService (
   //\r
   Status = Private->Udp6Read->Configure (Private->Udp6Read, &Private->Udp6CfgData);\r
   if (EFI_ERROR (Status)) {\r
   //\r
   Status = Private->Udp6Read->Configure (Private->Udp6Read, &Private->Udp6CfgData);\r
   if (EFI_ERROR (Status)) {\r
-    return Status;\r
+    goto ON_ERROR;\r
   }\r
     \r
   Status = PxeBc->UdpRead (\r
   }\r
     \r
   Status = PxeBc->UdpRead (\r
@@ -1041,7 +1042,7 @@ PxeBcRequestBootService (
   Private->Udp6Read->Configure (Private->Udp6Read, NULL);\r
 \r
   if (EFI_ERROR (Status)) {\r
   Private->Udp6Read->Configure (Private->Udp6Read, NULL);\r
 \r
   if (EFI_ERROR (Status)) {\r
-    return Status;\r
+    goto ON_ERROR;\r
   }\r
 \r
   //\r
   }\r
 \r
   //\r
@@ -1050,6 +1051,13 @@ PxeBcRequestBootService (
   Reply->Length = (UINT32) ReadSize;\r
 \r
   return EFI_SUCCESS;\r
   Reply->Length = (UINT32) ReadSize;\r
 \r
   return EFI_SUCCESS;\r
+  \r
+ON_ERROR:\r
+  if (Discover != NULL) {\r
+    FreePool (Discover);\r
+  }\r
+\r
+  return Status;\r
 }\r
 \r
 \r
 }\r
 \r
 \r
@@ -2158,7 +2166,7 @@ PxeBcDhcp6Discover (
                     (VOID *) Discover\r
                     );\r
   if (EFI_ERROR (Status)) {\r
                     (VOID *) Discover\r
                     );\r
   if (EFI_ERROR (Status)) {\r
-    return Status;\r
+    goto ON_ERROR;\r
   }\r
 \r
   //\r
   }\r
 \r
   //\r
@@ -2178,7 +2186,7 @@ PxeBcDhcp6Discover (
   //\r
   Status = Private->Udp6Read->Configure (Private->Udp6Read, &Private->Udp6CfgData);\r
   if (EFI_ERROR (Status)) {\r
   //\r
   Status = Private->Udp6Read->Configure (Private->Udp6Read, &Private->Udp6CfgData);\r
   if (EFI_ERROR (Status)) {\r
-    return Status;\r
+    goto ON_ERROR;\r
   }\r
   \r
   Status = PxeBc->UdpRead (\r
   }\r
   \r
   Status = PxeBc->UdpRead (\r
@@ -2198,10 +2206,17 @@ PxeBcDhcp6Discover (
   //\r
   Private->Udp6Read->Configure (Private->Udp6Read, NULL);\r
   if (EFI_ERROR (Status)) {\r
   //\r
   Private->Udp6Read->Configure (Private->Udp6Read, NULL);\r
   if (EFI_ERROR (Status)) {\r
-    return Status;\r
+    goto ON_ERROR;\r
   }\r
 \r
   return EFI_SUCCESS;\r
   }\r
 \r
   return EFI_SUCCESS;\r
+\r
+ON_ERROR:\r
+  if (Discover != NULL) {\r
+    FreePool (Discover);\r
+  }\r
+\r
+  return Status;\r
 }\r
 \r
 \r
 }\r
 \r
 \r
index 09c5753ad9e79938f1c129b350c3ad39aa9d8b2f..8dd787be1a00aed74701804713b3d7a6ff77ed75 100644 (file)
@@ -2,7 +2,7 @@
   Driver Binding functions implementationfor for UefiPxeBc Driver.\r
 \r
   (C) Copyright 2014 Hewlett-Packard Development Company, L.P.<BR>\r
   Driver Binding functions implementationfor for UefiPxeBc Driver.\r
 \r
   (C) Copyright 2014 Hewlett-Packard Development Company, L.P.<BR>\r
-  Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>\r
 \r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
 \r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
@@ -254,6 +254,7 @@ PxeBcDestroyIp4Children (
            &Private->PxeBc,\r
            NULL\r
            );\r
            &Private->PxeBc,\r
            NULL\r
            );\r
+    FreePool (Private->Ip4Nic->DevicePath);\r
 \r
     if (Private->Snp != NULL) { \r
       //\r
 \r
     if (Private->Snp != NULL) { \r
       //\r
@@ -414,6 +415,8 @@ PxeBcDestroyIp6Children (
            &Private->PxeBc,\r
            NULL\r
            );\r
            &Private->PxeBc,\r
            NULL\r
            );\r
+    FreePool (Private->Ip6Nic->DevicePath);\r
+    \r
     if (Private->Snp != NULL) {\r
       //\r
       // Close SNP from the child virtual handle\r
     if (Private->Snp != NULL) {\r
       //\r
       // Close SNP from the child virtual handle\r