ShellPkg: Fix conditionally uninitialized variables
Fixes CodeQL alerts for CWE-457: https://cwe.mitre.org/data/definitions/457.html Cc: Erich McMillan <emcmillan@microsoft.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Cc: Michael Kubacki <mikuback@linux.microsoft.com> Cc: Ray Ni <ray.ni@intel.com> Cc: Zhichao Gao <zhichao.gao@intel.com> Co-authored-by: Erich McMillan <emcmillan@microsoft.com> Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com> Reviewed-by: Zhichao Gao <zhichao.gao@intel.com> Reviewed-by: Oliver Smith-Denny <osd@smith-denny.com>
This commit is contained in:
committed by
mergify[bot]
parent
7dc182ed1e
commit
11dd44dfbe
@ -735,50 +735,52 @@ EfiShellGetDeviceName (
|
||||
//
|
||||
// Now check the parent controller using this as the child.
|
||||
//
|
||||
if (DeviceNameToReturn == NULL) {
|
||||
PARSE_HANDLE_DATABASE_PARENTS (DeviceHandle, &ParentControllerCount, &ParentControllerBuffer);
|
||||
Status = PARSE_HANDLE_DATABASE_PARENTS (DeviceHandle, &ParentControllerCount, &ParentControllerBuffer);
|
||||
if ((DeviceNameToReturn == NULL) && !EFI_ERROR (Status)) {
|
||||
for (LoopVar = 0; LoopVar < ParentControllerCount; LoopVar++) {
|
||||
PARSE_HANDLE_DATABASE_UEFI_DRIVERS (ParentControllerBuffer[LoopVar], &ParentDriverCount, &ParentDriverBuffer);
|
||||
for (HandleCount = 0; HandleCount < ParentDriverCount; HandleCount++) {
|
||||
//
|
||||
// try using that driver's component name with controller and our driver as the child.
|
||||
//
|
||||
Status = gBS->OpenProtocol (
|
||||
ParentDriverBuffer[HandleCount],
|
||||
&gEfiComponentName2ProtocolGuid,
|
||||
(VOID **)&CompName2,
|
||||
gImageHandle,
|
||||
NULL,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
Status = PARSE_HANDLE_DATABASE_UEFI_DRIVERS (ParentControllerBuffer[LoopVar], &ParentDriverCount, &ParentDriverBuffer);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
for (HandleCount = 0; HandleCount < ParentDriverCount; HandleCount++) {
|
||||
//
|
||||
// try using that driver's component name with controller and our driver as the child.
|
||||
//
|
||||
Status = gBS->OpenProtocol (
|
||||
ParentDriverBuffer[HandleCount],
|
||||
&gEfiComponentNameProtocolGuid,
|
||||
&gEfiComponentName2ProtocolGuid,
|
||||
(VOID **)&CompName2,
|
||||
gImageHandle,
|
||||
NULL,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
Status = gBS->OpenProtocol (
|
||||
ParentDriverBuffer[HandleCount],
|
||||
&gEfiComponentNameProtocolGuid,
|
||||
(VOID **)&CompName2,
|
||||
gImageHandle,
|
||||
NULL,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
);
|
||||
}
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Lang = GetBestLanguageForDriver (CompName2->SupportedLanguages, Language, FALSE);
|
||||
Status = CompName2->GetControllerName (CompName2, ParentControllerBuffer[LoopVar], DeviceHandle, Lang, &DeviceNameToReturn);
|
||||
FreePool (Lang);
|
||||
Lang = NULL;
|
||||
if (!EFI_ERROR (Status) && (DeviceNameToReturn != NULL)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Lang = GetBestLanguageForDriver (CompName2->SupportedLanguages, Language, FALSE);
|
||||
Status = CompName2->GetControllerName (CompName2, ParentControllerBuffer[LoopVar], DeviceHandle, Lang, &DeviceNameToReturn);
|
||||
FreePool (Lang);
|
||||
Lang = NULL;
|
||||
SHELL_FREE_NON_NULL (ParentDriverBuffer);
|
||||
if (!EFI_ERROR (Status) && (DeviceNameToReturn != NULL)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
SHELL_FREE_NON_NULL (ParentDriverBuffer);
|
||||
if (!EFI_ERROR (Status) && (DeviceNameToReturn != NULL)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
SHELL_FREE_NON_NULL (ParentControllerBuffer);
|
||||
|
Reference in New Issue
Block a user