X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;ds=sidebyside;f=ArmPlatformPkg%2FDrivers%2FNorFlashDxe%2FNorFlashDxe.c;h=3abbe5cb32bc2c7f44af3f014e6cb4515e022ff6;hb=ac83357a4311e008b229a8db43d2f1726cfe326d;hp=2f828ec86927210fecc5594370330d1ad4f8a473;hpb=2596e61a9b6a18c315f985bcb41cce3d498f9ad0;p=mirror_edk2.git diff --git a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c index 2f828ec869..3abbe5cb32 100644 --- a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c +++ b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c @@ -805,8 +805,7 @@ NorFlashRead ( OUT VOID *Buffer ) { - UINT32 NumBlocks; - UINTN StartAddress; + UINTN StartAddress; // The buffer must be valid if (Buffer == NULL) { @@ -818,15 +817,7 @@ NorFlashRead ( return EFI_SUCCESS; } - // All blocks must be within the device - NumBlocks = ((UINT32)BufferSizeInBytes) / Instance->Media.BlockSize ; - - if ((Lba + NumBlocks) > (Instance->Media.LastBlock + 1)) { - DEBUG ((EFI_D_ERROR, "NorFlashRead: ERROR - Read will exceed last block\n")); - return EFI_INVALID_PARAMETER; - } - - if (Offset + BufferSizeInBytes >= Instance->Size) { + if (((Lba * Instance->Media.BlockSize) + Offset + BufferSizeInBytes) > Instance->Size) { DEBUG ((EFI_D_ERROR, "NorFlashRead: ERROR - Read will exceed device size.\n")); return EFI_INVALID_PARAMETER; }