diff --git a/MdeModulePkg/Library/GenericBdsLib/BdsBoot.c b/MdeModulePkg/Library/GenericBdsLib/BdsBoot.c index 953086c7d3..d273e3f604 100644 --- a/MdeModulePkg/Library/GenericBdsLib/BdsBoot.c +++ b/MdeModulePkg/Library/GenericBdsLib/BdsBoot.c @@ -411,7 +411,7 @@ BdsExpandPartitionPartialDevicePathToFull ( // BdsLibConnectAllDriversToAllControllers (); Status = gBS->LocateHandleBuffer (ByProtocol, &gEfiBlockIoProtocolGuid, NULL, &BlockIoHandleCount, &BlockIoBuffer); - if (EFI_ERROR (Status) || BlockIoHandleCount == 0) { + if (EFI_ERROR (Status) || BlockIoHandleCount == 0 || BlockIoBuffer == NULL) { // // If there was an error or there are no device handles that support // the BLOCK_IO Protocol, then return. diff --git a/MdeModulePkg/Library/GenericBdsLib/BdsMisc.c b/MdeModulePkg/Library/GenericBdsLib/BdsMisc.c index b9e6ae7ef3..acf61ebcb6 100644 --- a/MdeModulePkg/Library/GenericBdsLib/BdsMisc.c +++ b/MdeModulePkg/Library/GenericBdsLib/BdsMisc.c @@ -1170,7 +1170,7 @@ BdsSetMemoryTypeInformationVariable ( &gEfiMemoryTypeInformationGuid, (VOID **) &CurrentMemoryTypeInformation ); - if (EFI_ERROR (Status)) { + if (EFI_ERROR (Status) || CurrentMemoryTypeInformation == NULL) { return; }