From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-BY2-obe.outbound.protection.outlook.com (mail-by2nam03on0724.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe4a::724]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id A615E82087 for ; Wed, 8 Feb 2017 00:13:02 -0800 (PST) Received: from CS1PR84MB0295.NAMPRD84.PROD.OUTLOOK.COM (10.162.190.26) by CS1PR84MB0294.NAMPRD84.PROD.OUTLOOK.COM (10.162.190.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.888.16; Wed, 8 Feb 2017 08:13:01 +0000 Received: from CS1PR84MB0295.NAMPRD84.PROD.OUTLOOK.COM ([10.162.190.26]) by CS1PR84MB0295.NAMPRD84.PROD.OUTLOOK.COM ([10.162.190.26]) with mapi id 15.01.0888.026; Wed, 8 Feb 2017 08:13:01 +0000 From: "Wang, Sunny (HPS SW)" To: Ruiyu Ni , "edk2-devel@lists.01.org" CC: Jeff Fan , "Wang, Sunny (HPS SW)" Thread-Topic: [edk2] [PATCH] MdeModulePkg/UefiBootManagerLib: Initialize Handle before using it Thread-Index: AQHSgO2AyU09RFJZvkOgZUTZVkAe46FeYCEg Date: Wed, 8 Feb 2017 08:13:00 +0000 Message-ID: References: <20170207025345.599532-1-ruiyu.ni@intel.com> In-Reply-To: <20170207025345.599532-1-ruiyu.ni@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=sunnywang@hpe.com; x-originating-ip: [15.211.131.4] x-microsoft-exchange-diagnostics: 1; CS1PR84MB0294; 7:FeKjoFURXzUDj9sspHcWYjuaSeJHBGn3leadfAmoZEKP8v1/EI6KJ9skwwcy6Qx392eKvv6lhlEYSVzhWFX1n5bg1bSXCPFN1xvO2MmNnGpS4NyM+JlJXGjIqJtAsXEgh+/ljcj1R4JvxJWa7aedrO2Fn6UaP3sfs22EU+upUkj1mw9fPeLXoGIS4YixAubcJcWYg874aB5lJJfD9dkL0cbbrApf4h3vS2thS/9u9TqbC+q2gs7gXjuquOPoFjHMvgLvpW7e79yP9/65557++yZnAARQVB3UdZrgKrPYRjfRAvCWuXKbyF1C5fB3fxtMUCpOSGNJWTNhpMhkI49iPMUMGQBh/AeJw1J8rn6bsK2+/Ii+moOyKzQNoTcXknMuI1WfH4dBLVd/pij9n5BdtUW6gkEnDO4GwemDPOS3Nb5fGIjBGUmNH/i4QRCSFQCSB9veVPf6B8oZtW2YBqB7DNPdtZON5xOw4rp3LNS9QtkI8x8TwAn7p7v4N6W3rX8Upa6Yi/d7IDuWZB277dT8TQ== x-forefront-antispam-report: SFV:SKI; SCL:-1SFV:NSPM; SFS:(10019020)(6009001)(7916002)(39410400002)(39860400002)(39850400002)(39840400002)(39450400003)(199003)(13464003)(189002)(377454003)(92566002)(53936002)(2950100002)(2900100001)(66066001)(68736007)(38730400002)(2501003)(8676002)(81156014)(7696004)(81166006)(8936002)(3660700001)(3280700002)(5660300001)(54356999)(122556002)(105586002)(101416001)(74316002)(54906002)(76176999)(9686003)(86362001)(106356001)(106116001)(7736002)(305945005)(77096006)(6306002)(189998001)(97736004)(33656002)(6246003)(6116002)(6436002)(6506006)(50986999)(102836003)(2906002)(229853002)(55016002)(3846002)(4326007); DIR:OUT; SFP:1102; SCL:1; SRVR:CS1PR84MB0294; H:CS1PR84MB0295.NAMPRD84.PROD.OUTLOOK.COM; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; x-ms-office365-filtering-correlation-id: b00d8ae5-61c8-4f31-9bc3-08d44ffa4c99 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(48565401081); SRVR:CS1PR84MB0294; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(227479698468861)(162533806227266)(228905959029699); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(6040375)(601004)(2401047)(8121501046)(20170203043)(5005006)(2017020702029)(3002001)(10201501046)(6055026)(6041248)(20161123555025)(20161123560025)(20161123558025)(20161123564025)(20161123562025)(6072148); SRVR:CS1PR84MB0294; BCL:0; PCL:0; RULEID:; SRVR:CS1PR84MB0294; x-forefront-prvs: 0212BDE3BE received-spf: None (protection.outlook.com: hpe.com does not designate permitted sender hosts) spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: hpe.com X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Feb 2017 08:13:00.9544 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 105b2061-b669-4b31-92ac-24d304d195dc X-MS-Exchange-Transport-CrossTenantHeadersStamped: CS1PR84MB0294 Subject: Re: [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: Wed, 08 Feb 2017 08:13:02 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Looks good to me.=20 Reviewed-by: Sunny Wang However, I saw the other potential issue below. If you also think the poten= tial issue is valid, you can fix this in the other patch. We need to consider the case where MDEPKG_NDEBUG is defined. We're using AS= SERT_EFI_ERROR to handle the error status from LocateDevicePath() in the fo= llowing code block, which contains potential bug that we still use uninitia= lized Handle for the case where LocateDevicePath returns error status.=20 Status =3D gBS->LocateDevicePath (&gEfiBlockIoProtocolGuid, &TempDevicePath= , &Handle); =20 ASSERT_EFI_ERROR (Status); -----Original Message----- From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Ruiy= u Ni Sent: Tuesday, February 07, 2017 10:54 AM To: edk2-devel@lists.01.org Cc: Jeff Fan Subject: [edk2] [PATCH] MdeModulePkg/UefiBootManagerLib: Initialize Handle = before using it BmExpandMediaDevicePath contains a bug that it uses the uninitialized Handl= e. Since the function is called when the Handle supports BlockIo or SimpleFile= System, 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 de= vice 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/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,=20 + &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.=20 + // should make sure all its children handles (its child partion or=20 + media handles) // are created and connected. // 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); -- 2.9.0.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel