To avoid potential NULL pointer dereference issue. Initialize them at
the beginning of the function.
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao Wu <hao.a.wu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Chen A Chen <chen.a.chen@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
EFI_GUID ImageTypeId;\r
UINTN ImageIndex;\r
\r
EFI_GUID ImageTypeId;\r
UINTN ImageIndex;\r
\r
- MapFsStr = NULL;\r
- CapsuleNum = 0;\r
+ BlockDescriptors = NULL;\r
+ MapFsStr = NULL;\r
+ CapsuleNum = 0;\r
\r
Status = GetArg();\r
if (EFI_ERROR(Status)) {\r
\r
Status = GetArg();\r
if (EFI_ERROR(Status)) {\r
UINTN FileCount;\r
BOOLEAN NoFile;\r
\r
UINTN FileCount;\r
BOOLEAN NoFile;\r
\r
- DirHandle = NULL;\r
- FileHandle = NULL;\r
- Index = 0;\r
- FileCount = 0;\r
- NoFile = FALSE;\r
+ DirHandle = NULL;\r
+ FileHandle = NULL;\r
+ Index = 0;\r
+ FileInfoBuffer = NULL;\r
+ FileInfo = NULL;\r
+ FileCount = 0;\r
+ NoFile = FALSE;\r
\r
Status = Fs->OpenVolume (Fs, &Root);\r
if (EFI_ERROR (Status)) {\r
\r
Status = Fs->OpenVolume (Fs, &Root);\r
if (EFI_ERROR (Status)) {\r
\r
ShellProtocol = GetShellProtocol ();\r
\r
\r
ShellProtocol = GetShellProtocol ();\r
\r
+ Index = 0;\r
+ CapsuleDataPtr64 = NULL;\r
+ BootNext = NULL;\r
+ ShellProtocol = NULL;\r
\r
//\r
// Dump capsule provisioned on Memory\r
\r
//\r
// Dump capsule provisioned on Memory\r
UINTN NumberEfiSystemPartitions;\r
EFI_SHELL_PROTOCOL *ShellProtocol;\r
\r
UINTN NumberEfiSystemPartitions;\r
EFI_SHELL_PROTOCOL *ShellProtocol;\r
\r
- ShellProtocol = GetShellProtocol ();\r
NumberEfiSystemPartitions = 0;\r
\r
NumberEfiSystemPartitions = 0;\r
\r
+ ShellProtocol = GetShellProtocol ();\r
+ if (ShellProtocol == NULL) {\r
+ Print (L"Get Shell Protocol Fail\n");;\r
+ return ;\r
+ }\r
+\r
Print (L"EFI System Partition list:\n");\r
\r
gBS->LocateHandleBuffer (\r
Print (L"EFI System Partition list:\n");\r
\r
gBS->LocateHandleBuffer (\r
EFI_BOOT_MANAGER_LOAD_OPTION NewOption;\r
\r
MappedDevicePath = NULL;\r
EFI_BOOT_MANAGER_LOAD_OPTION NewOption;\r
\r
MappedDevicePath = NULL;\r
+ BootOptionBuffer = NULL;\r
+\r
ShellProtocol = GetShellProtocol ();\r
ShellProtocol = GetShellProtocol ();\r
+ if (ShellProtocol == NULL) {\r
+ Print (L"Get Shell Protocol Fail\n");;\r
+ return EFI_NOT_FOUND;\r
+ }\r
\r
//\r
// 1. If Fs is not assigned and there are capsule provisioned before,\r
\r
//\r
// 1. If Fs is not assigned and there are capsule provisioned before,\r
// 2. Get EFI system partition form boot options.\r
//\r
BootOptionBuffer = EfiBootManagerGetLoadOptions (&BootOptionCount, LoadOptionTypeBoot);\r
// 2. Get EFI system partition form boot options.\r
//\r
BootOptionBuffer = EfiBootManagerGetLoadOptions (&BootOptionCount, LoadOptionTypeBoot);\r
- if (BootOptionCount == 0 && Map == NULL) {\r
+ if ( (BootOptionBuffer == NULL) ||\r
+ (BootOptionCount == 0 && Map == NULL)\r
+ ) {\r
return EFI_NOT_FOUND;\r
}\r
\r
return EFI_NOT_FOUND;\r
}\r
\r