diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c index 873930ce67..3a87298160 100644 --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c @@ -459,10 +459,6 @@ RuntimeServiceGetVariable ( return EFI_INVALID_PARAMETER; } - if ((*DataSize != 0) && (Data == NULL)) { - return EFI_INVALID_PARAMETER; - } - TempDataSize = *DataSize; VariableNameSize = StrSize (VariableName); SmmVariableHeader = NULL; @@ -527,7 +523,11 @@ RuntimeServiceGetVariable ( goto Done; } - CopyMem (Data, (UINT8 *)SmmVariableHeader->Name + SmmVariableHeader->NameSize, SmmVariableHeader->DataSize); + if (Data != NULL) { + CopyMem (Data, (UINT8 *)SmmVariableHeader->Name + SmmVariableHeader->NameSize, SmmVariableHeader->DataSize); + } else { + Status = EFI_INVALID_PARAMETER; + } Done: ReleaseLockOnlyAtBootTime (&mVariableServicesLock);