mirror of https://github.com/acidanthera/audk.git
MdeModulePkg/CapsuleApp: Fix potential NULL pointer dereference issue
To avoid potential NULL pointer dereference issue. Initialize them at
the beginning of the function. This patch is a supplement which was missed
at e98212cb5d
commit.
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao Wu <hao.a.wu@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Chen A Chen <chen.a.chen@intel.com>
Reviewed-by: Hao Wu <hao.a.wu@intel.com>
This commit is contained in:
parent
06516768ed
commit
1a35dd723b
|
@ -970,12 +970,15 @@ DumpProvisionedCapsule (
|
||||||
EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *Fs;
|
EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *Fs;
|
||||||
EFI_SHELL_PROTOCOL *ShellProtocol;
|
EFI_SHELL_PROTOCOL *ShellProtocol;
|
||||||
|
|
||||||
ShellProtocol = GetShellProtocol ();
|
|
||||||
|
|
||||||
Index = 0;
|
Index = 0;
|
||||||
CapsuleDataPtr64 = NULL;
|
CapsuleDataPtr64 = NULL;
|
||||||
BootNext = NULL;
|
BootNext = NULL;
|
||||||
ShellProtocol = NULL;
|
|
||||||
|
ShellProtocol = GetShellProtocol ();
|
||||||
|
if (ShellProtocol == NULL) {
|
||||||
|
Print (L"Get Shell Protocol Fail\n");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Dump capsule provisioned on Memory
|
// Dump capsule provisioned on Memory
|
||||||
|
@ -1002,16 +1005,16 @@ DumpProvisionedCapsule (
|
||||||
(VOID **) &CapsuleDataPtr64,
|
(VOID **) &CapsuleDataPtr64,
|
||||||
NULL
|
NULL
|
||||||
);
|
);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status) || CapsuleDataPtr64 == NULL) {
|
||||||
if (Index == 0) {
|
if (Index == 0) {
|
||||||
Print (L"No data.\n");
|
Print (L"No data.\n");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
} else {
|
|
||||||
Index++;
|
|
||||||
Print (L"Capsule Description at 0x%08x\n", *CapsuleDataPtr64);
|
|
||||||
DumpBlockDescriptors ((EFI_CAPSULE_BLOCK_DESCRIPTOR*) (UINTN) *CapsuleDataPtr64, DumpCapsuleInfo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Index++;
|
||||||
|
Print (L"Capsule Description at 0x%08x\n", *CapsuleDataPtr64);
|
||||||
|
DumpBlockDescriptors ((EFI_CAPSULE_BLOCK_DESCRIPTOR*) (UINTN) *CapsuleDataPtr64, DumpCapsuleInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -1026,7 +1029,9 @@ DumpProvisionedCapsule (
|
||||||
(VOID **) &BootNext,
|
(VOID **) &BootNext,
|
||||||
NULL
|
NULL
|
||||||
);
|
);
|
||||||
if (!EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status) || BootNext == NULL) {
|
||||||
|
Print (L"Get BootNext Variable Fail. Status = %r\n", Status);
|
||||||
|
} else {
|
||||||
UnicodeSPrint (BootOptionName, sizeof (BootOptionName), L"Boot%04x", *BootNext);
|
UnicodeSPrint (BootOptionName, sizeof (BootOptionName), L"Boot%04x", *BootNext);
|
||||||
Status = EfiBootManagerVariableToLoadOption (BootOptionName, &BootNextOptionEntry);
|
Status = EfiBootManagerVariableToLoadOption (BootOptionName, &BootNextOptionEntry);
|
||||||
if (!EFI_ERROR (Status)) {
|
if (!EFI_ERROR (Status)) {
|
||||||
|
|
|
@ -445,7 +445,10 @@ GetUpdateFileSystem (
|
||||||
(VOID **)&BootNextData,
|
(VOID **)&BootNextData,
|
||||||
NULL
|
NULL
|
||||||
);
|
);
|
||||||
if (!EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status) || BootNextData == NULL) {
|
||||||
|
Print (L"Get Boot Next Data Fail. Status = %r\n", Status);
|
||||||
|
return EFI_NOT_FOUND;
|
||||||
|
} else {
|
||||||
UnicodeSPrint (BootOptionName, sizeof (BootOptionName), L"Boot%04x", *BootNextData);
|
UnicodeSPrint (BootOptionName, sizeof (BootOptionName), L"Boot%04x", *BootNextData);
|
||||||
Status = EfiBootManagerVariableToLoadOption (BootOptionName, &BootNextOption);
|
Status = EfiBootManagerVariableToLoadOption (BootOptionName, &BootNextOption);
|
||||||
if (!EFI_ERROR (Status)) {
|
if (!EFI_ERROR (Status)) {
|
||||||
|
|
Loading…
Reference in New Issue