ArmPlatformPkg/BootMonFs: Cache the HW Description address
This fixes a bug whereby the image description is written over file data when the file's size is close to a multiple of the block size. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Brendan Jackman <brendan.jackman@arm.com> Reviewed-by: Olivier Martin <olivier.martin@arm.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15517 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
committed by
oliviermartin
parent
e29771bb6e
commit
79e12331ef
@@ -135,11 +135,12 @@ BootMonFsIsImageValid (
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
STATIC
|
||||
EFI_STATUS
|
||||
BootMonFsDiscoverNextImage (
|
||||
IN BOOTMON_FS_INSTANCE *Instance,
|
||||
IN EFI_LBA *LbaStart,
|
||||
OUT HW_IMAGE_DESCRIPTION *ImageDescription
|
||||
IN BOOTMON_FS_INSTANCE *Instance,
|
||||
IN OUT EFI_LBA *LbaStart,
|
||||
IN OUT BOOTMON_FS_FILE *File
|
||||
)
|
||||
{
|
||||
EFI_DISK_IO_PROTOCOL *DiskIo;
|
||||
@@ -162,17 +163,21 @@ BootMonFsDiscoverNextImage (
|
||||
Instance->Media->MediaId,
|
||||
DescOffset,
|
||||
sizeof (HW_IMAGE_DESCRIPTION),
|
||||
ImageDescription
|
||||
&File->HwDescription
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
// If we found a valid image description...
|
||||
if (BootMonFsIsImageValid (ImageDescription, (CurrentLba - Instance->Media->LowestAlignedLba))) {
|
||||
DEBUG ((EFI_D_ERROR, "Found image: %a in block %d.\n", &(ImageDescription->Footer.Filename), (UINTN)(CurrentLba - Instance->Media->LowestAlignedLba)));
|
||||
if (BootMonFsIsImageValid (&File->HwDescription, (CurrentLba - Instance->Media->LowestAlignedLba))) {
|
||||
DEBUG ((EFI_D_ERROR, "Found image: %a in block %d.\n",
|
||||
&(File->HwDescription.Footer.Filename),
|
||||
(UINTN)(CurrentLba - Instance->Media->LowestAlignedLba)
|
||||
));
|
||||
File->HwDescAddress = DescOffset;
|
||||
|
||||
*LbaStart = ImageDescription->BlockEnd + 1;
|
||||
*LbaStart = CurrentLba + 1;
|
||||
return EFI_SUCCESS;
|
||||
} else {
|
||||
CurrentLba++;
|
||||
@@ -202,7 +207,7 @@ BootMonFsInitialize (
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = BootMonFsDiscoverNextImage (Instance, &Lba, &(NewFile->HwDescription));
|
||||
Status = BootMonFsDiscoverNextImage (Instance, &Lba, NewFile);
|
||||
if (EFI_ERROR (Status)) {
|
||||
// Free NewFile allocated by BootMonFsCreateFile ()
|
||||
FreePool (NewFile);
|
||||
|
Reference in New Issue
Block a user