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
@ -1399,10 +1399,11 @@ ShellCommandCreateInitialMappingsAndPaths (
|
||||
CHAR16 *MapName;
|
||||
SHELL_MAP_LIST *MapListItem;
|
||||
|
||||
SplitCurDir = NULL;
|
||||
MapName = NULL;
|
||||
MapListItem = NULL;
|
||||
HandleList = NULL;
|
||||
ConsistMappingTable = NULL;
|
||||
SplitCurDir = NULL;
|
||||
MapName = NULL;
|
||||
MapListItem = NULL;
|
||||
HandleList = NULL;
|
||||
|
||||
//
|
||||
// Reset the static members back to zero
|
||||
@ -1458,32 +1459,35 @@ ShellCommandCreateInitialMappingsAndPaths (
|
||||
//
|
||||
PerformQuickSort (DevicePathList, Count, sizeof (EFI_DEVICE_PATH_PROTOCOL *), DevicePathCompare);
|
||||
|
||||
ShellCommandConsistMappingInitialize (&ConsistMappingTable);
|
||||
//
|
||||
// Assign new Mappings to all...
|
||||
//
|
||||
for (Count = 0; HandleList[Count] != NULL; Count++) {
|
||||
if (!EFI_ERROR (ShellCommandConsistMappingInitialize (&ConsistMappingTable))) {
|
||||
//
|
||||
// Get default name first
|
||||
// Assign new Mappings to all...
|
||||
//
|
||||
NewDefaultName = ShellCommandCreateNewMappingName (MappingTypeFileSystem);
|
||||
ASSERT (NewDefaultName != NULL);
|
||||
Status = ShellCommandAddMapItemAndUpdatePath (NewDefaultName, DevicePathList[Count], 0, TRUE);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
FreePool (NewDefaultName);
|
||||
|
||||
//
|
||||
// Now do consistent name
|
||||
//
|
||||
NewConsistName = ShellCommandConsistMappingGenMappingName (DevicePathList[Count], ConsistMappingTable);
|
||||
if (NewConsistName != NULL) {
|
||||
Status = ShellCommandAddMapItemAndUpdatePath (NewConsistName, DevicePathList[Count], 0, FALSE);
|
||||
for (Count = 0; HandleList[Count] != NULL; Count++) {
|
||||
//
|
||||
// Get default name first
|
||||
//
|
||||
NewDefaultName = ShellCommandCreateNewMappingName (MappingTypeFileSystem);
|
||||
ASSERT (NewDefaultName != NULL);
|
||||
Status = ShellCommandAddMapItemAndUpdatePath (NewDefaultName, DevicePathList[Count], 0, TRUE);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
FreePool (NewConsistName);
|
||||
FreePool (NewDefaultName);
|
||||
|
||||
//
|
||||
// Now do consistent name
|
||||
//
|
||||
NewConsistName = ShellCommandConsistMappingGenMappingName (DevicePathList[Count], ConsistMappingTable);
|
||||
if (NewConsistName != NULL) {
|
||||
Status = ShellCommandAddMapItemAndUpdatePath (NewConsistName, DevicePathList[Count], 0, FALSE);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
FreePool (NewConsistName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ShellCommandConsistMappingUnInitialize (ConsistMappingTable);
|
||||
if (ConsistMappingTable != NULL) {
|
||||
ShellCommandConsistMappingUnInitialize (ConsistMappingTable);
|
||||
}
|
||||
|
||||
SHELL_FREE_NON_NULL (HandleList);
|
||||
SHELL_FREE_NON_NULL (DevicePathList);
|
||||
@ -1626,12 +1630,12 @@ ShellCommandUpdateMapping (
|
||||
//
|
||||
PerformQuickSort (DevicePathList, Count, sizeof (EFI_DEVICE_PATH_PROTOCOL *), DevicePathCompare);
|
||||
|
||||
ShellCommandConsistMappingInitialize (&ConsistMappingTable);
|
||||
Status = ShellCommandConsistMappingInitialize (&ConsistMappingTable);
|
||||
|
||||
//
|
||||
// Assign new Mappings to remainders
|
||||
//
|
||||
for (Count = 0; !EFI_ERROR (Status) && HandleList[Count] != NULL && !EFI_ERROR (Status); Count++) {
|
||||
for (Count = 0; !EFI_ERROR (Status) && HandleList[Count] != NULL; Count++) {
|
||||
//
|
||||
// Skip ones that already have
|
||||
//
|
||||
|
Reference in New Issue
Block a user