mirror of
https://github.com/acidanthera/audk.git
synced 2025-07-25 22:54:51 +02:00
MdeModulePkg/TerminalDxe: Avoid always append device path to *Dev
When TerminalDxe Start() is called multiple times, the old logic unconditionally appended the terminal device path candidates to *Dev (ConInDev/ConOutDev/ErrOutDev), resulting the volatile storage is full. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com> Reviewed-by: Star Zeng <star.zeng@intel.com>
This commit is contained in:
parent
4395f82e7f
commit
b9c04b88a1
@ -993,6 +993,49 @@ TerminalDriverBindingStop (
|
|||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Compare a device path data structure to that of all the nodes of a
|
||||||
|
second device path instance.
|
||||||
|
|
||||||
|
@param Multi A pointer to a multi-instance device path data structure.
|
||||||
|
@param Single A pointer to a single-instance device path data structure.
|
||||||
|
|
||||||
|
@retval TRUE If the Single is contained within Multi.
|
||||||
|
@retval FALSE The Single is not match within Multi.
|
||||||
|
|
||||||
|
**/
|
||||||
|
BOOLEAN
|
||||||
|
MatchDevicePaths (
|
||||||
|
IN EFI_DEVICE_PATH_PROTOCOL *Multi,
|
||||||
|
IN EFI_DEVICE_PATH_PROTOCOL *Single
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
|
||||||
|
EFI_DEVICE_PATH_PROTOCOL *DevicePathInst;
|
||||||
|
UINTN Size;
|
||||||
|
|
||||||
|
DevicePath = Multi;
|
||||||
|
DevicePathInst = GetNextDevicePathInstance (&DevicePath, &Size);
|
||||||
|
//
|
||||||
|
// Search for the match of 'Single' in 'Multi'
|
||||||
|
//
|
||||||
|
while (DevicePathInst != NULL) {
|
||||||
|
//
|
||||||
|
// If the single device path is found in multiple device paths,
|
||||||
|
// return success
|
||||||
|
//
|
||||||
|
if (CompareMem (Single, DevicePathInst, Size) == 0) {
|
||||||
|
FreePool (DevicePathInst);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
FreePool (DevicePathInst);
|
||||||
|
DevicePathInst = GetNextDevicePathInstance (&DevicePath, &Size);
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Update terminal device path in Console Device Environment Variables.
|
Update terminal device path in Console Device Environment Variables.
|
||||||
|
|
||||||
@ -1018,8 +1061,12 @@ TerminalUpdateConsoleDevVariable (
|
|||||||
//
|
//
|
||||||
// Get global variable and its size according to the name given.
|
// Get global variable and its size according to the name given.
|
||||||
//
|
//
|
||||||
GetEfiGlobalVariable2 (VariableName, (VOID**)&Variable, NULL);
|
Status = GetEfiGlobalVariable2 (VariableName, (VOID**)&Variable, NULL);
|
||||||
if (Variable == NULL) {
|
if (Status == EFI_NOT_FOUND) {
|
||||||
|
Status = EFI_SUCCESS;
|
||||||
|
Variable = NULL;
|
||||||
|
}
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1028,17 +1075,21 @@ TerminalUpdateConsoleDevVariable (
|
|||||||
//
|
//
|
||||||
for (TerminalType = 0; TerminalType < ARRAY_SIZE (mTerminalType); TerminalType++) {
|
for (TerminalType = 0; TerminalType < ARRAY_SIZE (mTerminalType); TerminalType++) {
|
||||||
SetTerminalDevicePath (TerminalType, ParentDevicePath, &TempDevicePath);
|
SetTerminalDevicePath (TerminalType, ParentDevicePath, &TempDevicePath);
|
||||||
NewVariable = AppendDevicePathInstance (Variable, TempDevicePath);
|
|
||||||
ASSERT (NewVariable != NULL);
|
|
||||||
if (Variable != NULL) {
|
|
||||||
FreePool (Variable);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (TempDevicePath != NULL) {
|
if (TempDevicePath != NULL) {
|
||||||
|
if (!MatchDevicePaths (Variable, TempDevicePath)) {
|
||||||
|
NewVariable = AppendDevicePathInstance (Variable, TempDevicePath);
|
||||||
|
if (NewVariable != NULL) {
|
||||||
|
if (Variable != NULL) {
|
||||||
|
FreePool (Variable);
|
||||||
|
}
|
||||||
|
Variable = NewVariable;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
FreePool (TempDevicePath);
|
FreePool (TempDevicePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
Variable = NewVariable;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VariableSize = GetDevicePathSize (Variable);
|
VariableSize = GetDevicePathSize (Variable);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user