summaryrefslogtreecommitdiffstats
path: root/MdeModulePkg/Library/UefiBootManagerLib
diff options
context:
space:
mode:
authorRuiyu Ni <ruiyu.ni@intel.com>2017-02-06 10:00:33 +0800
committerRuiyu Ni <ruiyu.ni@intel.com>2017-02-08 17:46:31 +0800
commit00e39b0939574d7c2ce5dbd14f0aa2c1297e42fe (patch)
tree1098d6870a901fb89cb9077e05f0164137671e47 /MdeModulePkg/Library/UefiBootManagerLib
parentcc20411062137e5d820a33db73d41f97dae74368 (diff)
downloadedk2-00e39b0939574d7c2ce5dbd14f0aa2c1297e42fe.tar.gz
edk2-00e39b0939574d7c2ce5dbd14f0aa2c1297e42fe.tar.bz2
edk2-00e39b0939574d7c2ce5dbd14f0aa2c1297e42fe.zip
MdeModulePkg/UefiBootManagerLib: Initialize Handle before using it
BmExpandMediaDevicePath contains a bug that it uses the uninitialized Handle. Since the function is called when the Handle supports BlockIo or SimpleFileSystem, when there is no SimpleFileSystem installed on the Handle, BlockIo is *guaranteed* to be installed on the Handle. The fix initializes the Handle by locating the BlockIo protocol from the device path. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com> Cc: Jeff Fan <jeff.fan@intel.com> Reviewed-by: Sunny Wang <sunnywang@hpe.com>
Diffstat (limited to 'MdeModulePkg/Library/UefiBootManagerLib')
-rw-r--r--MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
index 75bd5dcfb0..8a3a4027ee 100644
--- a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
+++ b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
@@ -991,9 +991,13 @@ BmExpandMediaDevicePath (
return FileBuffer;
}
+ Status = gBS->LocateDevicePath (&gEfiBlockIoProtocolGuid, &TempDevicePath, &Handle);
+ ASSERT_EFI_ERROR (Status);
+
//
- // For device boot option only pointing to the removable device handle,
- // should make sure all its children handles (its child partion or media handles) are created and connected.
+ // For device boot option only pointing to the removable device handle,
+ // should make sure all its children handles (its child partion or media handles)
+ // are created and connected.
//
gBS->ConnectController (Handle, NULL, NULL, TRUE);
@@ -1004,8 +1008,6 @@ BmExpandMediaDevicePath (
// returned. After the Block IO protocol is reinstalled, subsequent
// Block IO read/write will success.
//
- Status = gBS->LocateDevicePath (&gEfiBlockIoProtocolGuid, &TempDevicePath, &Handle);
- ASSERT_EFI_ERROR (Status);
Status = gBS->HandleProtocol (Handle, &gEfiBlockIoProtocolGuid, (VOID **) &BlockIo);
ASSERT_EFI_ERROR (Status);
Buffer = AllocatePool (BlockIo->Media->BlockSize);