mirror of https://github.com/acidanthera/audk.git
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
This commit is contained in:
parent
3de99375d2
commit
969ece79f1
|
@ -424,7 +424,7 @@ MmcIoBlocks (
|
||||||
UINT32 Response[4];
|
UINT32 Response[4];
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
UINTN CardSize, NumBlocks, BlockSize, CmdArg;
|
UINTN CardSize, NumBlocks, BlockSize, CmdArg;
|
||||||
UINTN Timeout;
|
INTN Timeout;
|
||||||
UINTN Cmd;
|
UINTN Cmd;
|
||||||
MMC_HOST_INSTANCE *MmcHostInstance;
|
MMC_HOST_INSTANCE *MmcHostInstance;
|
||||||
EFI_MMC_HOST_PROTOCOL *MmcHost;
|
EFI_MMC_HOST_PROTOCOL *MmcHost;
|
||||||
|
@ -436,7 +436,7 @@ MmcIoBlocks (
|
||||||
MmcHost = MmcHostInstance->MmcHost;
|
MmcHost = MmcHostInstance->MmcHost;
|
||||||
ASSERT(MmcHost);
|
ASSERT(MmcHost);
|
||||||
|
|
||||||
if (MmcHost == 0) {
|
if ((MmcHost == 0)|| (Buffer == NULL)) {
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -445,7 +445,7 @@ MmcIoBlocks (
|
||||||
return EFI_NO_MEDIA;
|
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) {
|
if (MmcHostInstance->State == MmcHwInitializationState) {
|
||||||
MmcIdentificationMode (MmcHostInstance);
|
MmcIdentificationMode (MmcHostInstance);
|
||||||
|
|
||||||
|
@ -508,14 +508,24 @@ MmcIoBlocks (
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Lba > This->Media->LastBlock) {
|
// All blocks must be within the device
|
||||||
ASSERT(0);
|
if ((Lba + (BufferSize / This->Media->BlockSize)) > (This->Media->LastBlock + 1)){
|
||||||
return EFI_INVALID_PARAMETER;
|
ASSERT(0);
|
||||||
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((BufferSize % This->Media->BlockSize) != 0) {
|
// The buffer size must not be zero and it must be an exact multiple of the block size
|
||||||
ASSERT(0);
|
if ((BufferSize == 0) || ((BufferSize % This->Media->BlockSize) != 0)) {
|
||||||
return EFI_BAD_BUFFER_SIZE;
|
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;
|
BytesRemainingToBeTransfered = BufferSize;
|
||||||
|
|
Loading…
Reference in New Issue