ArmPkg/BdsLib: Free the memory when Linux fails to start

Not freeing the memory prevents Linux to be started again.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Olivier Martin <olivier.martin@arm.com>



git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@14193 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
oliviermartin
2013-03-12 01:02:44 +00:00
parent 7e91decd13
commit a90e327921
2 changed files with 59 additions and 20 deletions

View File

@@ -310,7 +310,7 @@ PrepareFdt (
Status = gBS->AllocatePages (AllocateAnyPages, EfiBootServicesData, EFI_SIZE_TO_PAGES(NewFdtBlobSize), &NewFdtBlobBase);
if (EFI_ERROR(Status)) {
ASSERT_EFI_ERROR(Status);
goto FAIL_NEW_FDT;
goto FAIL_ALLOCATE_NEW_FDT;
} else {
DEBUG ((EFI_D_WARN, "WARNING: Loaded FDT at random address 0x%lX.\nWARNING: There is a risk of accidental overwriting by other code/data.\n", NewFdtBlobBase));
}
@@ -515,12 +515,18 @@ PrepareFdt (
//DebugDumpFdt (fdt);
DEBUG_CODE_END();
// If we succeeded to generate the new Device Tree then free the old Device Tree
gBS->FreePages (*FdtBlobBase, EFI_SIZE_TO_PAGES (*FdtBlobSize));
*FdtBlobBase = NewFdtBlobBase;
*FdtBlobSize = (UINTN)fdt_totalsize ((VOID*)(UINTN)(NewFdtBlobBase));
return EFI_SUCCESS;
FAIL_NEW_FDT:
*FdtBlobSize = OriginalFdtSize;
gBS->FreePages (NewFdtBlobBase, EFI_SIZE_TO_PAGES (NewFdtBlobSize));
FAIL_ALLOCATE_NEW_FDT:
*FdtBlobSize = (UINTN)fdt_totalsize ((VOID*)(UINTN)(*FdtBlobBase));
// Return success even if we failed to update the FDT blob. The original one is still valid.
return EFI_SUCCESS;
}