ShellPkg/Shell: Check the OpenVolume result in OpenRootByHandle()

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=779

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 <jaben.carsey@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
This commit is contained in:
Hao Wu 2017-11-14 13:29:03 +08:00
parent 1fbe8276c4
commit 996bd353d2
1 changed files with 7 additions and 2 deletions

View File

@ -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 Others Error status returned from EFI_SIMPLE_FILE_SYSTEM_PROTOCOL->OpenVolume().
**/
EFI_STATUS
EFIAPI
@ -867,8 +868,12 @@ EfiShellOpenRootByHandle(
// Open the root volume now...
//
Status = SimpleFileSystem->OpenVolume(SimpleFileSystem, &RealFileHandle);
if (EFI_ERROR(Status)) {
return Status;
}
*FileHandle = ConvertEfiFileProtocolToShellHandle(RealFileHandle, EfiShellGetMapFromDevicePath(&DevPath));
return (Status);
return (EFI_SUCCESS);
}
/**