]> git.proxmox.com Git - mirror_edk2.git/blobdiff - NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c
NetworkPkg: Fix memory leak problem in PXE driver.
[mirror_edk2.git] / NetworkPkg / UefiPxeBcDxe / PxeBcDhcp6.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
+      FreePool (TmpStr);\r
       return EFI_INVALID_PARAMETER;\r
     }\r
 \r
@@ -1005,7 +1006,7 @@ PxeBcRequestBootService (
                     );\r
 \r
   if (EFI_ERROR (Status)) {\r
-    return Status;\r
+    goto ON_ERROR;\r
   }\r
 \r
   //\r
@@ -1020,7 +1021,7 @@ PxeBcRequestBootService (
   //\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
@@ -1041,7 +1042,7 @@ PxeBcRequestBootService (
   Private->Udp6Read->Configure (Private->Udp6Read, NULL);\r
 \r
   if (EFI_ERROR (Status)) {\r
-    return Status;\r
+    goto ON_ERROR;\r
   }\r
 \r
   //\r
@@ -1050,6 +1051,13 @@ PxeBcRequestBootService (
   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
@@ -2158,7 +2166,7 @@ PxeBcDhcp6Discover (
                     (VOID *) Discover\r
                     );\r
   if (EFI_ERROR (Status)) {\r
-    return Status;\r
+    goto ON_ERROR;\r
   }\r
 \r
   //\r
@@ -2178,7 +2186,7 @@ PxeBcDhcp6Discover (
   //\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
@@ -2198,10 +2206,17 @@ PxeBcDhcp6Discover (
   //\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
+ON_ERROR:\r
+  if (Discover != NULL) {\r
+    FreePool (Discover);\r
+  }\r
+\r
+  return Status;\r
 }\r
 \r
 \r