From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.24; helo=mga09.intel.com; envelope-from=hao.a.wu@intel.com; receiver=edk2-devel@lists.01.org Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by ml01.01.org (Postfix) with ESMTP id 041872035BB1F for ; Tue, 14 Nov 2017 02:39:28 -0800 (PST) Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Nov 2017 00:41:05 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,393,1505804400"; d="scan'208";a="173288937" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by orsmga005.jf.intel.com with ESMTP; 14 Nov 2017 00:41:05 -0800 Received: from fmsmsx152.amr.corp.intel.com (10.18.125.5) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 14 Nov 2017 00:41:04 -0800 Received: from shsmsx102.ccr.corp.intel.com (10.239.4.154) by FMSMSX152.amr.corp.intel.com (10.18.125.5) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 14 Nov 2017 00:41:03 -0800 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.152]) by shsmsx102.ccr.corp.intel.com ([169.254.2.175]) with mapi id 14.03.0319.002; Tue, 14 Nov 2017 16:41:01 +0800 From: "Wu, Hao A" To: "Ni, Ruiyu" , "edk2-devel@lists.01.org" CC: "Carsey, Jaben" Thread-Topic: [PATCH] ShellPkg/Shell: Check the OpenVolume result in OpenRootByHandle() Thread-Index: AQHTXR21pm4wN3N6P0qYrrvBlPPYJqMTB2IAgACGpnA= Date: Tue, 14 Nov 2017 08:41:01 +0000 Message-ID: References: <20171114075333.12024-1-hao.a.wu@intel.com> <734D49CCEBEEF84792F5B80ED585239D5BABFAE8@SHSMSX104.ccr.corp.intel.com> In-Reply-To: <734D49CCEBEEF84792F5B80ED585239D5BABFAE8@SHSMSX104.ccr.corp.intel.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH] ShellPkg/Shell: Check the OpenVolume result in OpenRootByHandle() X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Nov 2017 10:39:29 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable > -----Original Message----- > From: Ni, Ruiyu > Sent: Tuesday, November 14, 2017 4:38 PM > To: Wu, Hao A; edk2-devel@lists.01.org > Cc: Carsey, Jaben > Subject: RE: [PATCH] ShellPkg/Shell: Check the OpenVolume result in > OpenRootByHandle() >=20 > How about changing the function header comments from > > + @retval EFI_MEDIA_CHANGED The device has a different medium in i= t > or the medium is no longer supported. >=20 > To: > > + @retval others Error status returned from > EFI_SIMPLE_FILE_SYSTEM_PROTOCOL->OpenVolume(). >=20 > Because MEDIA_CHANGED is not the only error that could happen. Yes, I will update the comments when I push the patch if there's no other comments. Best Regards, Hao Wu >=20 >=20 > Thanks/Ray >=20 > > -----Original Message----- > > From: Wu, Hao A > > Sent: Tuesday, November 14, 2017 3:54 PM > > To: edk2-devel@lists.01.org > > Cc: Wu, Hao A ; Carsey, Jaben > > ; Ni, Ruiyu > > Subject: [PATCH] ShellPkg/Shell: Check the OpenVolume result in > > OpenRootByHandle() > > > > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D779 > > > > For the API EfiShellOpenRootByHandle(): > > > > The return status of the call to SimpleFileSystem->OpenVolume should be > > checked. > > > > It is possible that there is a media change in the device (like CD/DVD = ROM). > In > > such case, the volume root opened and/or the device path opened previou= sly > > (also within EfiShellOpenRootByHandle) may be invalid. > > > > This commit adds a check for the result of OpenVolume before subsequent= ly > > calling functions like EfiShellGetMapFromDevicePath() & > > ConvertEfiFileProtocolToShellHandle(). > > > > Cc: Jaben Carsey > > Cc: Ruiyu Ni > > Contributed-under: TianoCore Contribution Agreement 1.1 > > Signed-off-by: Hao Wu > > --- > > ShellPkg/Application/Shell/ShellProtocol.c | 9 +++++++-- > > 1 file changed, 7 insertions(+), 2 deletions(-) > > > > diff --git a/ShellPkg/Application/Shell/ShellProtocol.c > > b/ShellPkg/Application/Shell/ShellProtocol.c > > index 5e34b8dad1..0dee267353 100644 > > --- a/ShellPkg/Application/Shell/ShellProtocol.c > > +++ b/ShellPkg/Application/Shell/ShellProtocol.c > > @@ -827,7 +827,8 @@ EfiShellGetDeviceName( > > @retval EFI_NOT_FOUND EFI_SIMPLE_FILE_SYSTEM could not be > found > > or the root directory > > could not be opened. > > @retval EFI_VOLUME_CORRUPTED The data structures in the volume > were > > corrupted. > > - @retval EFI_DEVICE_ERROR The device had an error > > + @retval EFI_DEVICE_ERROR The device had an error. > > + @retval EFI_MEDIA_CHANGED The device has a different medium in i= t > or > > the medium is no longer supported. > > **/ > > EFI_STATUS > > EFIAPI > > @@ -867,8 +868,12 @@ EfiShellOpenRootByHandle( > > // Open the root volume now... > > // > > Status =3D SimpleFileSystem->OpenVolume(SimpleFileSystem, > &RealFileHandle); > > + if (EFI_ERROR(Status)) { > > + return Status; > > + } > > + > > *FileHandle =3D ConvertEfiFileProtocolToShellHandle(RealFileHandle, > > EfiShellGetMapFromDevicePath(&DevPath)); > > - return (Status); > > + return (EFI_SUCCESS); > > } > > > > /** > > -- > > 2.12.0.windows.1