summaryrefslogtreecommitdiff
path: root/ArmPlatformPkg/Drivers/NorFlashDxe
diff options
context:
space:
mode:
authorRonald Cron <ronald.cron@arm.com>2015-01-23 16:09:07 +0000
committeroliviermartin <oliviermartin@Edk2>2015-01-23 16:09:07 +0000
commitac83357a4311e008b229a8db43d2f1726cfe326d (patch)
tree507a139b0f87d5d8a98750530c2a22af4f9311dc /ArmPlatformPkg/Drivers/NorFlashDxe
parent2596e61a9b6a18c315f985bcb41cce3d498f9ad0 (diff)
downloadedk2-platforms-ac83357a4311e008b229a8db43d2f1726cfe326d.tar.xz
ArmPkg/NorFlashDxe : Fix the check of flash addresses
Fix the check to prevent any reading past the end of the nor flash. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ronald Cron <ronald.cron@arm.com> Reviewed-by: Olivier Martin <olivier.martin@arm.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16655 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'ArmPlatformPkg/Drivers/NorFlashDxe')
-rw-r--r--ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c13
1 files changed, 2 insertions, 11 deletions
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;
}