From nobody Sat Nov 2 14:32:51 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zoho.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1486436062798672.1254641140522; Mon, 6 Feb 2017 18:54:22 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 5A3518204E; Mon, 6 Feb 2017 18:54:20 -0800 (PST) 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 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 X-Original-To: edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,344,1477983600"; d="scan'208";a="61975720" From: Ruiyu Ni To: edk2-devel@lists.01.org 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: [edk2] [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: , Cc: Jeff Fan MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Sunny Wang --- MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c b/MdeModulePk= g/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; } =20 + Status =3D gBS->LocateDevicePath (&gEfiBlockIoProtocolGuid, &TempDeviceP= ath, &Handle); + ASSERT_EFI_ERROR (Status); + // // For device boot option only pointing to the removable device handle,=20 - // should make sure all its children handles (its child partion or media= handles) are created and connected.=20 + // should make sure all its children handles (its child partion or media= handles) + // are created and connected.=20 // gBS->ConnectController (Handle, NULL, NULL, TRUE); =20 @@ -1004,8 +1008,6 @@ BmExpandMediaDevicePath ( // returned. After the Block IO protocol is reinstalled, subsequent // Block IO read/write will success. // - Status =3D gBS->LocateDevicePath (&gEfiBlockIoProtocolGuid, &TempDeviceP= ath, &Handle); - ASSERT_EFI_ERROR (Status); Status =3D gBS->HandleProtocol (Handle, &gEfiBlockIoProtocolGuid, (VOID = **) &BlockIo); ASSERT_EFI_ERROR (Status); Buffer =3D AllocatePool (BlockIo->Media->BlockSize); --=20 2.9.0.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel