From nobody Thu May 2 20:12:12 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.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 1510646020833491.43785482178; Mon, 13 Nov 2017 23:53:40 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 2A3AA220D4BF0; Mon, 13 Nov 2017 23:49:32 -0800 (PST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (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 B2E93220D4BEB for ; Mon, 13 Nov 2017 23:49:30 -0800 (PST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Nov 2017 23:53:37 -0800 Received: from shwdeopenpsi014.ccr.corp.intel.com ([10.239.9.13]) by fmsmga002.fm.intel.com with ESMTP; 13 Nov 2017 23:53:36 -0800 X-Original-To: edk2-devel@lists.01.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; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.20; helo=mga02.intel.com; envelope-from=hao.a.wu@intel.com; receiver=edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,393,1505804400"; d="scan'208";a="1243809165" From: Hao Wu To: edk2-devel@lists.01.org Date: Tue, 14 Nov 2017 15:53:33 +0800 Message-Id: <20171114075333.12024-1-hao.a.wu@intel.com> X-Mailer: git-send-email 2.12.0.windows.1 Subject: [edk2] [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: , Cc: Hao Wu , Jaben Carsey , Ruiyu Ni 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" 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 previously (also within EfiShellOpenRootByHandle) may be invalid. This commit adds a check for the result of OpenVolume before subsequently calling functions like EfiShellGetMapFromDevicePath() & ConvertEfiFileProtocolToShellHandle(). Cc: Jaben Carsey Cc: Ruiyu Ni Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Hao Wu Reviewed-by: Ruiyu Ni --- ShellPkg/Application/Shell/ShellProtocol.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ShellPkg/Application/Shell/ShellProtocol.c b/ShellPkg/Applicat= ion/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 cor= rupted. - @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, &RealFileHandl= e); + if (EFI_ERROR(Status)) { + return Status; + } + *FileHandle =3D ConvertEfiFileProtocolToShellHandle(RealFileHandle, EfiS= hellGetMapFromDevicePath(&DevPath)); - return (Status); + return (EFI_SUCCESS); } =20 /** --=20 2.12.0.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel