public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Vladimir Olovyannikov <vladimir.olovyannikov@broadcom.com>
To: edk2-devel@lists.01.org, tapandshah@hpe.com, jaben.carsey@intel.com
Cc: Vladimir Olovyannikov <volovyan@broadcom.com>,
	Vladimir Olovyannikov <vladimir.olovyannikov@broadcom.com>
Subject: [PATCH] ShellPkg: Fix erroneous Status returned by ShellOpenFileByName()
Date: Thu,  6 Oct 2016 14:40:07 -0700	[thread overview]
Message-ID: <1475790007-16365-1-git-send-email-vladimir.olovyannikov@broadcom.com> (raw)

From: Vladimir Olovyannikov <volovyan@broadcom.com>

In ShellOpenFileByName() the file is opened using
gEfiShellProtocol->OpenFileByName().
It is supposed that if this call returns an EFI_ERROR, the function
should return that error immediately. However, this return was missing,
and if UnicodeCollationProtocol has not been located by this time, the
Status gets overwritten with LocateProtocol() call result, which
eventually erroneously returns EFI_SUCCESS to the Shell.c, and this
leads to attempt to execute a non-existent startup script, which fails,
and which in turn leads to Shell being unloaded with "Invalid parameter"
error. This patch fixes the bug.

Cc: Tapan Shah <tapandshah@hpe.com>
Cc: Jaben Carsey <jaben.carsey@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Vladimir Olovyannikov <vladimir.olovyannikov@broadcom.com>
---
 ShellPkg/Library/UefiShellLib/UefiShellLib.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/ShellPkg/Library/UefiShellLib/UefiShellLib.c b/ShellPkg/Library/UefiShellLib/UefiShellLib.c
index 53f54e1746d4..6fa67a3e751c 100644
--- a/ShellPkg/Library/UefiShellLib/UefiShellLib.c
+++ b/ShellPkg/Library/UefiShellLib/UefiShellLib.c
@@ -723,6 +723,8 @@ ShellOpenFileByName(
     Status = gEfiShellProtocol->OpenFileByName(FileName,
                                                FileHandle,
                                                OpenMode);
+    if (EFI_ERROR(Status)) {
+      return Status;
 
     if (mUnicodeCollationProtocol == NULL) {
       Status = gBS->LocateProtocol (&gEfiUnicodeCollation2ProtocolGuid, NULL, (VOID**)&mUnicodeCollationProtocol);
-- 
1.9.1



             reply	other threads:[~2016-10-06 21:40 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-06 21:40 Vladimir Olovyannikov [this message]
2016-10-06 21:51 ` [PATCH] ShellPkg: Fix erroneous Status returned by ShellOpenFileByName() Shah, Tapan
2016-10-06 21:52   ` Vladimir Olovyannikov
  -- strict thread matches above, loose matches on Subject: below --
2016-10-06 22:02 Vladimir Olovyannikov
2016-10-06 22:03 ` Shah, Tapan
2016-10-07 17:36   ` Carsey, Jaben

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=1475790007-16365-1-git-send-email-vladimir.olovyannikov@broadcom.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