OvmfPkg: QemuVideoDxe: tidy up error checking/handling in & under Start()
In QemuVideoControllerDriverStart(): - remove redundant zero-initialization of: - Private->Handle (2 locations) - Private->GopDevicePath (when at devpath end) - remove fields used for error handling only: - PciAttributesSaved - tigthen scope of temporaries: - MmioDesc - AcpiDeviceNode - supplement missing error checks: - AppendDevicePathNode() can fail with out-of-memory (2 locations) - when installing GopDevicePath - retval of QemuVideoGraphicsOutputConstructor() (can justifiedly fail with out-of-resources) - plug leaks on error: - free GopDevicePath (AppendDevicePathNode() allocates dynamically) - uninstall GopDevicePath - free Private->ModeData - call QemuVideoGraphicsOutputDestructor() - uninstall GOP In QemuVideoGraphicsOutputConstructor(), called by Start(): - supplement missing error checks: - QemuVideoGraphicsOutputSetMode() retval (it can fail with out-of-resources) - plug leaks on error: - free Mode->Info - free Mode In QemuVideoCirrusModeSetup() and QemuVideoBochsModeSetup(), both called by Start(): - supplement missing error checks: - AllocatePool() can fail in both In QemuVideoGraphicsOutputDestructor(), called by Start() on the error path: - plug leaks: - free Private->LineBuffer, which is allocated in Start() -> Constructor() -> SetMode() In QemuVideoGraphicsOutputSetMode(), called by Start() indirectly: - remove redundant zero-assignment to: - Private->LineBuffer Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Jordan Justen <jordan.l.justen@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15282 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
@@ -176,7 +176,6 @@ Routine Description:
|
||||
gBS->FreePool (Private->LineBuffer);
|
||||
}
|
||||
|
||||
Private->LineBuffer = NULL;
|
||||
Private->LineBuffer = AllocatePool (4 * ModeData->HorizontalResolution);
|
||||
if (Private->LineBuffer == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
@@ -321,13 +320,14 @@ QemuVideoGraphicsOutputConstructor (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = gBS->AllocatePool (
|
||||
EfiBootServicesData,
|
||||
sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION),
|
||||
(VOID **) &Private->GraphicsOutput.Mode->Info
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
goto FreeMode;
|
||||
}
|
||||
Private->GraphicsOutput.Mode->MaxMode = (UINT32) Private->MaxMode;
|
||||
Private->GraphicsOutput.Mode->Mode = GRAPHICS_OUTPUT_INVALIDE_MODE_NUMBER;
|
||||
@@ -337,7 +337,11 @@ QemuVideoGraphicsOutputConstructor (
|
||||
//
|
||||
// Initialize the hardware
|
||||
//
|
||||
GraphicsOutput->SetMode (GraphicsOutput, 0);
|
||||
Status = GraphicsOutput->SetMode (GraphicsOutput, 0);
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto FreeInfo;
|
||||
}
|
||||
|
||||
DrawLogo (
|
||||
Private,
|
||||
Private->ModeData[Private->GraphicsOutput.Mode->Mode].HorizontalResolution,
|
||||
@@ -345,6 +349,15 @@ QemuVideoGraphicsOutputConstructor (
|
||||
);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
|
||||
FreeInfo:
|
||||
FreePool (Private->GraphicsOutput.Mode->Info);
|
||||
|
||||
FreeMode:
|
||||
FreePool (Private->GraphicsOutput.Mode);
|
||||
Private->GraphicsOutput.Mode = NULL;
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
@@ -363,6 +376,10 @@ Returns:
|
||||
|
||||
--*/
|
||||
{
|
||||
if (Private->LineBuffer != NULL) {
|
||||
FreePool (Private->LineBuffer);
|
||||
}
|
||||
|
||||
if (Private->GraphicsOutput.Mode != NULL) {
|
||||
if (Private->GraphicsOutput.Mode->Info != NULL) {
|
||||
gBS->FreePool (Private->GraphicsOutput.Mode->Info);
|
||||
|
Reference in New Issue
Block a user