OUT VOID *Buffer\r
)\r
{\r
- UINT32 NumBlocks;\r
- UINTN StartAddress;\r
+ UINTN StartAddress;\r
\r
// The buffer must be valid\r
if (Buffer == NULL) {\r
return EFI_SUCCESS;\r
}\r
\r
- // All blocks must be within the device\r
- NumBlocks = ((UINT32)BufferSizeInBytes) / Instance->Media.BlockSize ;\r
-\r
- if ((Lba + NumBlocks) > (Instance->Media.LastBlock + 1)) {\r
- DEBUG ((EFI_D_ERROR, "NorFlashRead: ERROR - Read will exceed last block\n"));\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- if (Offset + BufferSizeInBytes >= Instance->Size) {\r
+ if (((Lba * Instance->Media.BlockSize) + Offset + BufferSizeInBytes) > Instance->Size) {\r
DEBUG ((EFI_D_ERROR, "NorFlashRead: ERROR - Read will exceed device size.\n"));\r
return EFI_INVALID_PARAMETER;\r
}\r