]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg: Fix memory leak issues
authorSunny Wang <sunnywang@hpe.com>
Tue, 3 Nov 2015 02:58:30 +0000 (02:58 +0000)
committerniruiyu <niruiyu@Edk2>
Tue, 3 Nov 2015 02:58:30 +0000 (02:58 +0000)
Fix memory leak issues

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Sunny Wang <sunnywang@hpe.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18722 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Library/UefiBootManagerLib/BmConsole.c

index 86b4fac4241e33bf754fd42465ea7c330e2458c8..a13917bd0844638ef9959e5ee8caa6beb287d700 100644 (file)
@@ -2,6 +2,7 @@
   Library functions which contain all the code to connect console device.\r
 \r
 Copyright (c) 2011 - 2015, Intel Corporation. All rights reserved.<BR>\r
+(C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -301,6 +302,7 @@ BmUpdateSystemTableConsole (
   EFI_DEVICE_PATH_PROTOCOL        *FullDevicePath;\r
   EFI_DEVICE_PATH_PROTOCOL        *VarConsole;\r
   EFI_DEVICE_PATH_PROTOCOL        *Instance;\r
+  EFI_DEVICE_PATH_PROTOCOL        *FullInstance;\r
   VOID                            *Interface;\r
   EFI_HANDLE                      NewHandle;\r
   EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *TextOut;\r
@@ -354,11 +356,13 @@ BmUpdateSystemTableConsole (
     //\r
     // Find console device handle by device path instance\r
     //\r
+    FullInstance = Instance;\r
     Status = gBS->LocateDevicePath (\r
                     ConsoleGuid,\r
                     &Instance,\r
                     &NewHandle\r
                     );\r
+    FreePool (FullInstance);\r
     if (!EFI_ERROR (Status)) {\r
       //\r
       // Get the console protocol on this console device handle\r
@@ -383,6 +387,7 @@ BmUpdateSystemTableConsole (
             TextOut->SetMode (TextOut, 0);\r
           }\r
         }\r
+        FreePool (FullDevicePath);\r
         return TRUE;\r
       }\r
     }\r
@@ -392,6 +397,7 @@ BmUpdateSystemTableConsole (
   //\r
   // No any available console devcie found.\r
   //\r
+  FreePool (FullDevicePath);\r
   return FALSE;\r
 }\r
 \r