]> git.proxmox.com Git - mirror_edk2.git/blobdiff - OvmfPkg/QemuVideoDxe/Gop.c
OvmfPkg: QemuVideoDxe: tidy up error checking/handling in & under Start()
[mirror_edk2.git] / OvmfPkg / QemuVideoDxe / Gop.c
index 30aac7f95fa89b07b692bc3734d043f1df5fa57a..1b7db329b9b3e585a6c3c8e1d66dfef436b403a7 100644 (file)
@@ -176,7 +176,6 @@ Routine Description:
     gBS->FreePool (Private->LineBuffer);\r
   }\r
 \r
-  Private->LineBuffer = NULL;\r
   Private->LineBuffer = AllocatePool (4 * ModeData->HorizontalResolution);\r
   if (Private->LineBuffer == NULL) {\r
     return EFI_OUT_OF_RESOURCES;\r
@@ -321,13 +320,14 @@ QemuVideoGraphicsOutputConstructor (
   if (EFI_ERROR (Status)) {\r
     return Status;\r
   }\r
+\r
   Status = gBS->AllocatePool (\r
                   EfiBootServicesData,\r
                   sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION),\r
                   (VOID **) &Private->GraphicsOutput.Mode->Info\r
                   );\r
   if (EFI_ERROR (Status)) {\r
-    return Status;\r
+    goto FreeMode;\r
   }\r
   Private->GraphicsOutput.Mode->MaxMode = (UINT32) Private->MaxMode;\r
   Private->GraphicsOutput.Mode->Mode    = GRAPHICS_OUTPUT_INVALIDE_MODE_NUMBER;\r
@@ -337,7 +337,11 @@ QemuVideoGraphicsOutputConstructor (
   //\r
   // Initialize the hardware\r
   //\r
-  GraphicsOutput->SetMode (GraphicsOutput, 0);\r
+  Status = GraphicsOutput->SetMode (GraphicsOutput, 0);\r
+  if (EFI_ERROR (Status)) {\r
+    goto FreeInfo;\r
+  }\r
+\r
   DrawLogo (\r
     Private,\r
     Private->ModeData[Private->GraphicsOutput.Mode->Mode].HorizontalResolution,\r
@@ -345,6 +349,15 @@ QemuVideoGraphicsOutputConstructor (
     );\r
 \r
   return EFI_SUCCESS;\r
+\r
+FreeInfo:\r
+  FreePool (Private->GraphicsOutput.Mode->Info);\r
+\r
+FreeMode:\r
+  FreePool (Private->GraphicsOutput.Mode);\r
+  Private->GraphicsOutput.Mode = NULL;\r
+\r
+  return Status;\r
 }\r
 \r
 EFI_STATUS\r
@@ -363,6 +376,10 @@ Returns:
 \r
 --*/\r
 {\r
+  if (Private->LineBuffer != NULL) {\r
+    FreePool (Private->LineBuffer);\r
+  }\r
+\r
   if (Private->GraphicsOutput.Mode != NULL) {\r
     if (Private->GraphicsOutput.Mode->Info != NULL) {\r
       gBS->FreePool (Private->GraphicsOutput.Mode->Info);\r