From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id ACCA681FC8 for ; Mon, 6 Feb 2017 18:54:18 -0800 (PST) Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga102.fm.intel.com with ESMTP; 06 Feb 2017 18:54:18 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,344,1477983600"; d="scan'208";a="61975720" Received: from ray-dev.ccr.corp.intel.com ([10.239.9.25]) by fmsmga005.fm.intel.com with ESMTP; 06 Feb 2017 18:54:17 -0800 From: Ruiyu Ni To: edk2-devel@lists.01.org Cc: Jeff Fan Date: Tue, 7 Feb 2017 10:53:45 +0800 Message-Id: <20170207025345.599532-1-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.9.0.windows.1 Subject: [PATCH] MdeModulePkg/UefiBootManagerLib: Initialize Handle before using it X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 07 Feb 2017 02:54:18 -0000 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 should 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 Cc: Jeff Fan --- MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c index 75bd5dc..9f99122 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. + // 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); -- 2.9.0.windows.1