From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qk0-x22b.google.com (mail-qk0-x22b.google.com [IPv6:2607:f8b0:400d:c09::22b]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 7A8CD1A1DFF for ; Thu, 6 Oct 2016 15:02:29 -0700 (PDT) Received: by mail-qk0-x22b.google.com with SMTP id z190so15832676qkc.2 for ; Thu, 06 Oct 2016 15:02:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id; bh=FL4mqnPwS6/sYjwqzbf42SQuXn0N/99KKVWVNY/wGMk=; b=N/OK2OviACH4rWBf9nWNO224BCzaajMs8aeYkeqSnnVqmLkpqKGPy4rxZnQ5s3yEQj pXx/hqW0FWUzyHCedG+vXoTfi8yFMWtgjCUz2LUahu3cU+NEQEdZ0UA/aa7zJl4EPAL0 qa8fnkLDHnNVsFS+suzelNA1PXFXon9qdhbRI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=FL4mqnPwS6/sYjwqzbf42SQuXn0N/99KKVWVNY/wGMk=; b=b8nbjUZTSbjN8KIjgeaorvgaMC5PQMcG89WZw+Qc7lBtmwgVI/B/WrQZsoB7fSJr8C AXYOG7BbURGQ/QM5zyqJ2XRT1171/jWT4z0/m9NSf4uibpvg1E2JjMj8v+6Qt+QK8XYp sSHzpGFFXpt+5b4yHkR1GtnyYqu4mcGa7Obi7XwWE8qGsEQSTQcWVQ3btMNBZlxKHOIY b3Lu8AF02SqC5DBWSq5KlHnH2DUxcaEHnU2ZbJRZD+vc1zQqo93+8u+upxO9EoWagg/n aaUoAlikxNgMz2aZ1Xy6l4jKNCaYvyyfDJSmWQs7eg9uNM3Z2nrwnEn1kAQCjs/Fjd0A 8uUw== X-Gm-Message-State: AA6/9Rm5/mhZWnTejqC4mAvnORjxFhhTemIfttWoKGbFww379Q+CwFBLx05V5r6vABFQIZ2h X-Received: by 10.55.40.40 with SMTP id o40mr14437069qkh.73.1475791348256; Thu, 06 Oct 2016 15:02:28 -0700 (PDT) Received: from LBRMN-LNXUB114.ric.broadcom.com ([216.31.219.19]) by smtp.gmail.com with ESMTPSA id 8sm1552980qty.36.2016.10.06.15.02.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 06 Oct 2016 15:02:27 -0700 (PDT) From: Vladimir Olovyannikov To: edk2-devel@lists.01.org, tapandshah@hpe.com, jaben.carsey@intel.com Cc: Vladimir Olovyannikov Date: Thu, 6 Oct 2016 15:02:26 -0700 Message-Id: <1475791346-17316-1-git-send-email-vladimir.olovyannikov@broadcom.com> X-Mailer: git-send-email 1.9.1 Subject: [PATCH] ShellPkg: Fix erroneous Status returned by ShellOpenFileByName() X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Oct 2016 22:02:29 -0000 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 Cc: Jaben Carsey Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Vladimir Olovyannikov --- 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