Skip to content

Commit

Permalink
Fix memory leak and also detect failed memory allocation
Browse files Browse the repository at this point in the history
  • Loading branch information
vincent-j-zimmer committed Dec 20, 2024
1 parent a4768f4 commit cdea7f5
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,23 @@ ApplyGfxConfigToPolicy (
GfxEnablePort0 = *(BOOLEAN *)ConfigBuffer;
GfxSiliconPolicy = AllocateCopyPool (sizeof (DefaultQemuGfxPolicy), DefaultQemuGfxPolicy);

if (GfxSiliconPolicy == NULL) {
DEBUG ((DEBUG_ERROR, "Failed to allocate Policy structure\n"));
goto Exit;
} // Mu

// We only translate the GFX ports #0 exposed to platform from conf data
GfxSiliconPolicy[0].Power_State_Port = GfxEnablePort0;

Status = SetPolicy (&gPolicyDataGFXGuid, POLICY_ATTRIBUTE_FINALIZED, GfxSiliconPolicy, sizeof (DefaultQemuGfxPolicy));

if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a Failed to update GFX policy per configuration data - %r!!!\n", __func__, Status));
ASSERT (FALSE);
FreePool (GfxSiliconPolicy); //Mu
goto Exit;
}

FreePool (GfxSiliconPolicy); //Mu
Exit:
return Status;
}

0 comments on commit cdea7f5

Please sign in to comment.