summaryrefslogtreecommitdiff
path: root/EmbeddedPkg/Universal/MmcDxe
diff options
context:
space:
mode:
authoroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>2011-08-15 16:06:53 +0000
committeroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>2011-08-15 16:06:53 +0000
commit969ece79f161fb4ddcb2b370af7975a66b8f58e7 (patch)
treea586ef0b36ce6ac6da855995058bdd9018766ced /EmbeddedPkg/Universal/MmcDxe
parent3de99375d289d2945192be9e38fce63224d27b21 (diff)
downloadedk2-platforms-969ece79f161fb4ddcb2b370af7975a66b8f58e7.tar.xz
EmbeddedPkg/MmcDxe: Improved parameters checking
Ensure the passed parameters are correct. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12129 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'EmbeddedPkg/Universal/MmcDxe')
-rw-r--r--EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c28
1 files changed, 19 insertions, 9 deletions
diff --git a/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c b/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c
index cd04369652..887cb96a16 100644
--- a/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c
+++ b/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c
@@ -424,7 +424,7 @@ MmcIoBlocks (
UINT32 Response[4];
EFI_STATUS Status;
UINTN CardSize, NumBlocks, BlockSize, CmdArg;
- UINTN Timeout;
+ INTN Timeout;
UINTN Cmd;
MMC_HOST_INSTANCE *MmcHostInstance;
EFI_MMC_HOST_PROTOCOL *MmcHost;
@@ -436,7 +436,7 @@ MmcIoBlocks (
MmcHost = MmcHostInstance->MmcHost;
ASSERT(MmcHost);
- if (MmcHost == 0) {
+ if ((MmcHost == 0)|| (Buffer == NULL)) {
return EFI_INVALID_PARAMETER;
}
@@ -445,7 +445,7 @@ MmcIoBlocks (
return EFI_NO_MEDIA;
}
- // If the driver has not been initialized yet then go into Iddentification Mode
+ // If the driver has not been initialized yet then go into Identification Mode
if (MmcHostInstance->State == MmcHwInitializationState) {
MmcIdentificationMode (MmcHostInstance);
@@ -508,14 +508,24 @@ MmcIoBlocks (
}
}
- if (Lba > This->Media->LastBlock) {
- ASSERT(0);
- return EFI_INVALID_PARAMETER;
+ // All blocks must be within the device
+ if ((Lba + (BufferSize / This->Media->BlockSize)) > (This->Media->LastBlock + 1)){
+ ASSERT(0);
+ return EFI_INVALID_PARAMETER;
}
- if ((BufferSize % This->Media->BlockSize) != 0) {
- ASSERT(0);
- return EFI_BAD_BUFFER_SIZE;
+ // The buffer size must not be zero and it must be an exact multiple of the block size
+ if ((BufferSize == 0) || ((BufferSize % This->Media->BlockSize) != 0)) {
+ ASSERT(0);
+ return EFI_BAD_BUFFER_SIZE;
+ }
+
+ if (This->Media->MediaId != MediaId) {
+ return EFI_MEDIA_CHANGED;
+ }
+
+ if((Transfer == MMC_IOBLOCKS_WRITE) && (This->Media->ReadOnly == TRUE)) {
+ return EFI_WRITE_PROTECTED;
}
BytesRemainingToBeTransfered = BufferSize;