]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootOption.c
MdeModulePkg/BootMaintUi: Add error handling codes when AllocatePool fail
[mirror_edk2.git] / MdeModulePkg / Library / BootMaintenanceManagerUiLib / BootOption.c
index c660c731458a286ce14e216e3de227c3212e919e..890728aff5b69cfc2867b12633ceeed25c1178eb 100644 (file)
@@ -865,29 +865,33 @@ BootFromFile (
   EFI_BOOT_MANAGER_LOAD_OPTION BootOption;\r
   CHAR16                       *FileName;\r
 \r
+  FileName = NULL;\r
+\r
   FileName = ExtractFileNameFromDevicePath(FilePath);\r
-  EfiBootManagerInitializeLoadOption (\r
-    &BootOption,\r
-    0,\r
-    LoadOptionTypeBoot,\r
-    LOAD_OPTION_ACTIVE,\r
-    FileName,\r
-    FilePath,\r
-    NULL,\r
-    0\r
-    );\r
-  //\r
-  // Since current no boot from removable media directly is allowed */\r
-  //\r
-  gST->ConOut->ClearScreen (gST->ConOut);\r
+  if (FileName != NULL) {\r
+    EfiBootManagerInitializeLoadOption (\r
+      &BootOption,\r
+      0,\r
+      LoadOptionTypeBoot,\r
+      LOAD_OPTION_ACTIVE,\r
+      FileName,\r
+      FilePath,\r
+      NULL,\r
+      0\r
+      );\r
+    //\r
+    // Since current no boot from removable media directly is allowed */\r
+    //\r
+    gST->ConOut->ClearScreen (gST->ConOut);\r
 \r
-  BmmSetConsoleMode (FALSE);\r
-  EfiBootManagerBoot (&BootOption);\r
-  BmmSetConsoleMode (TRUE);\r
+    BmmSetConsoleMode (FALSE);\r
+    EfiBootManagerBoot (&BootOption);\r
+    BmmSetConsoleMode (TRUE);\r
 \r
-  FreePool(FileName);\r
+    FreePool(FileName);\r
 \r
-  EfiBootManagerFreeLoadOption (&BootOption);\r
+    EfiBootManagerFreeLoadOption (&BootOption);\r
+  }\r
 \r
   return FALSE;\r
 }\r