From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.43; helo=mga05.intel.com; envelope-from=ruiyu.ni@intel.com; receiver=edk2-devel@lists.01.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (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 244A1220D4C1E for ; Tue, 14 Nov 2017 00:33:51 -0800 (PST) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Nov 2017 00:37:58 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,393,1505804400"; d="scan'208";a="1329234" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by fmsmga004.fm.intel.com with ESMTP; 14 Nov 2017 00:37:58 -0800 Received: from fmsmsx154.amr.corp.intel.com (10.18.116.70) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 14 Nov 2017 00:37:57 -0800 Received: from shsmsx102.ccr.corp.intel.com (10.239.4.154) by FMSMSX154.amr.corp.intel.com (10.18.116.70) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 14 Nov 2017 00:37:57 -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:37:55 +0800 From: "Ni, Ruiyu" To: "Wu, Hao A" , "edk2-devel@lists.01.org" CC: "Carsey, Jaben" Thread-Topic: [PATCH] ShellPkg/Shell: Check the OpenVolume result in OpenRootByHandle() Thread-Index: AQHTXR21z0zudiwVKEqVBHPzCbWATqMTjPMQ Date: Tue, 14 Nov 2017 08:37:54 +0000 Message-ID: <734D49CCEBEEF84792F5B80ED585239D5BABFAE8@SHSMSX104.ccr.corp.intel.com> References: <20171114075333.12024-1-hao.a.wu@intel.com> In-Reply-To: <20171114075333.12024-1-hao.a.wu@intel.com> Accept-Language: en-US, zh-CN 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 08:33:51 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable How about changing the function header comments from > + @retval EFI_MEDIA_CHANGED The device has a different medium in it = or the medium is no longer supported. To: > + @retval others Error status returned from EFI_SIMPLE_FILE_SYSTEM_PROT= OCOL->OpenVolume(). Because MEDIA_CHANGED is not the only error that could happen. Thanks/Ray > -----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() >=20 > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D779 >=20 > For the API EfiShellOpenRootByHandle(): >=20 > The return status of the call to SimpleFileSystem->OpenVolume should be > checked. >=20 > It is possible that there is a media change in the device (like CD/DVD RO= M). In > such case, the volume root opened and/or the device path opened previousl= y > (also within EfiShellOpenRootByHandle) may be invalid. >=20 > This commit adds a check for the result of OpenVolume before subsequently > calling functions like EfiShellGetMapFromDevicePath() & > ConvertEfiFileProtocolToShellHandle(). >=20 > 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(-) >=20 > 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 foun= d > 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 it = 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, &RealFileHan= dle); > + if (EFI_ERROR(Status)) { > + return Status; > + } > + > *FileHandle =3D ConvertEfiFileProtocolToShellHandle(RealFileHandle, > EfiShellGetMapFromDevicePath(&DevPath)); > - return (Status); > + return (EFI_SUCCESS); > } >=20 > /** > -- > 2.12.0.windows.1