public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Ni, Ruiyu" <ruiyu.ni@intel.com>
To: "Wu, Hao A" <hao.a.wu@intel.com>,
	"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Cc: "Carsey, Jaben" <jaben.carsey@intel.com>
Subject: Re: [PATCH] ShellPkg/Shell: Check the OpenVolume result in OpenRootByHandle()
Date: Tue, 14 Nov 2017 08:37:54 +0000	[thread overview]
Message-ID: <734D49CCEBEEF84792F5B80ED585239D5BABFAE8@SHSMSX104.ccr.corp.intel.com> (raw)
In-Reply-To: <20171114075333.12024-1-hao.a.wu@intel.com>

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_PROTOCOL->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 <hao.a.wu@intel.com>; Carsey, Jaben
> <jaben.carsey@intel.com>; Ni, Ruiyu <ruiyu.ni@intel.com>
> Subject: [PATCH] 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>
> Cc: Ruiyu Ni <ruiyu.ni@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Hao Wu <hao.a.wu@intel.com>
> ---
>  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 it or
> the medium is no longer supported.
>  **/
>  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);
>  }
> 
>  /**
> --
> 2.12.0.windows.1



  reply	other threads:[~2017-11-14  8:33 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-14  7:53 [PATCH] ShellPkg/Shell: Check the OpenVolume result in OpenRootByHandle() Hao Wu
2017-11-14  8:37 ` Ni, Ruiyu [this message]
2017-11-14  8:41   ` Wu, Hao A
2017-11-14  8:42     ` Ni, Ruiyu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=734D49CCEBEEF84792F5B80ED585239D5BABFAE8@SHSMSX104.ccr.corp.intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox