-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix memory leak and also detect failed memory allocation #1084
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have stopped using MU_CHANGE tags in mu_tiano_platforms because we have completely forked from edk2, so nothing for us to track anymore. Otherwise LGTM!
if (GfxSiliconPolicy == NULL) { | ||
DEBUG ((DEBUG_ERROR, "Failed to allocate Policy structure\n")); | ||
goto Exit; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like Status
will be uninitialized in this goto Exit
path.
if (GfxSiliconPolicy == NULL) { | |
DEBUG ((DEBUG_ERROR, "Failed to allocate Policy structure\n")); | |
goto Exit; | |
if (GfxSiliconPolicy == NULL) { | |
DEBUG ((DEBUG_ERROR, "Failed to allocate Policy structure\n")); | |
Status = EFI_OUT_OF_RESOURCES; | |
goto Exit; |
Should add EFI_OUT_OF_RESOURCES
to the function return values if this is done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good suggestion. Updated w/ recommendations.
if (GfxSiliconPolicy == NULL) { | ||
DEBUG ((DEBUG_ERROR, "Failed to allocate Policy structure\n")); | ||
goto Exit; | ||
} // Mu |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} // Mu | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mentioned in Oliver's comment, the "Mu" comments can be dropped.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense. Updated w/ recommendation.
// 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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not related to your change, but I suggest updating this assert so it is more useful when printed. ASSERT (FALSE)
is not very helpful.
ASSERT (FALSE); | |
ASSERT_EFI_ERROR (Status); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good suggestion. Updated w/ recommendations.
CI is failing because uncrustify needs to be run. I suggest you do that following the VS Code plugin instructions here: https://github.com/tianocore/tianocore.github.io/wiki/EDK-II-Code-Formatting#recommended-usage-visual-studio-vs-code-plugin |
Description
Fixes #632
This change is responsive to #632. It fixes a memory leak and also defends against a failed memory allocation.
How This Was Tested
Build test and boot to shell using QEMU
Integration Instructions
N/A