public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Shah, Tapan" <tapandshah@hpe.com>
To: Vladimir Olovyannikov <vladimir.olovyannikov@broadcom.com>,
	"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>,
	"jaben.carsey@intel.com" <jaben.carsey@intel.com>
Subject: Re: [PATCH] ShellPkg: Fix erroneous Status returned by ShellOpenFileByName()
Date: Thu, 6 Oct 2016 22:03:43 +0000	[thread overview]
Message-ID: <CS1PR84MB0229F64EB4DF3E7687F401B4D4C70@CS1PR84MB0229.NAMPRD84.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <1475791346-17316-1-git-send-email-vladimir.olovyannikov@broadcom.com>

Reviewed-by: Tapan Shah <tapandshah@hpe.com>


-----Original Message-----
From: Vladimir Olovyannikov [mailto:vladimir.olovyannikov@broadcom.com] 
Sent: Thursday, October 06, 2016 5:02 PM
To: edk2-devel@lists.01.org; Shah, Tapan <tapandshah@hpe.com>; jaben.carsey@intel.com
Cc: Vladimir Olovyannikov <vladimir.olovyannikov@broadcom.com>
Subject: [PATCH] ShellPkg: Fix erroneous Status returned by ShellOpenFileByName()

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 | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/ShellPkg/Library/UefiShellLib/UefiShellLib.c b/ShellPkg/Library/UefiShellLib/UefiShellLib.c
index 53f54e1746d4..8db18b3b210f 100644
--- a/ShellPkg/Library/UefiShellLib/UefiShellLib.c
+++ b/ShellPkg/Library/UefiShellLib/UefiShellLib.c
@@ -723,6 +723,9 @@ 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 22:03 UTC|newest]

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

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=CS1PR84MB0229F64EB4DF3E7687F401B4D4C70@CS1PR84MB0229.NAMPRD84.PROD.OUTLOOK.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