]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmPlatformPkg/Bds: Fixed memory leak
authorOlivier Martin <olivier.martin@arm.com>
Fri, 12 Dec 2014 19:11:56 +0000 (19:11 +0000)
committeroliviermartin <oliviermartin@Edk2>
Fri, 12 Dec 2014 19:11:56 +0000 (19:11 +0000)
Device Paths were not freed after calling
BDS_LOAD_OPTION_SUPPORT.CreateDevicePathNode()

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Olivier Martin <olivier.martin@arm.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16514 6f19259b-4bc3-4df7-8a09-765794883524

ArmPlatformPkg/Bds/BootMenu.c

index 91e00b759ee48bb2073c34907f5f4d3f4b215d46..3a72df0495e5ab4b3ecefc1d33460ca5785987de 100644 (file)
@@ -341,6 +341,9 @@ BootMenuAddBootOption (
       if (InitrdPathNodes != NULL) {\r
         // Append the Device Path to the selected device path\r
         InitrdPath = AppendDevicePath (SupportedBootDevice->DevicePathProtocol, (CONST EFI_DEVICE_PATH_PROTOCOL *)InitrdPathNodes);\r
+        // Free the InitrdPathNodes created by Support->CreateDevicePathNode()\r
+        FreePool (InitrdPathNodes);\r
+\r
         if (InitrdPath == NULL) {\r
           Status = EFI_OUT_OF_RESOURCES;\r
           goto EXIT;\r
@@ -540,6 +543,8 @@ BootMenuUpdateBootOption (
           // Append the Device Path to the selected device path\r
           InitrdPath = AppendDevicePath (TempInitrdPath, (CONST EFI_DEVICE_PATH_PROTOCOL *)InitrdPathNodes);\r
           FreePool (TempInitrdPath);\r
+          // Free the InitrdPathNodes created by Support->CreateDevicePathNode()\r
+          FreePool (InitrdPathNodes);\r
           if (InitrdPath == NULL) {\r
             Status = EFI_OUT_OF_RESOURCES;\r
             goto EXIT;\r
@@ -846,6 +851,8 @@ UpdateFdtPath (
   if (FdtDevicePathNodes != NULL) {\r
     // Append the Device Path node to the select device path\r
     FdtDevicePath = AppendDevicePath (SupportedBootDevice->DevicePathProtocol, FdtDevicePathNodes);\r
+    // Free the FdtDevicePathNodes created by Support->CreateDevicePathNode()\r
+    FreePool (FdtDevicePathNodes);\r
     FdtDevicePathSize = GetDevicePathSize (FdtDevicePath);\r
     Status = gRT->SetVariable (\r
                     (CHAR16*)L"Fdt",\r