From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.65; helo=mga03.intel.com; envelope-from=fan.wang@intel.com; receiver=edk2-devel@lists.01.org Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 5A38C2035D336 for ; Mon, 8 Jan 2018 17:14:03 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Jan 2018 17:19:13 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,333,1511856000"; d="scan'208";a="8181724" Received: from fanwang2-hp.ccr.corp.intel.com ([10.239.9.33]) by fmsmga007.fm.intel.com with ESMTP; 08 Jan 2018 17:19:12 -0800 From: Wang Fan To: edk2-devel@lists.01.org Cc: Jiaxin Wu , Ye Ting , Fu Siyuan Date: Tue, 9 Jan 2018 09:19:06 +0800 Message-Id: <1515460747-8372-2-git-send-email-fan.wang@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1515460747-8372-1-git-send-email-fan.wang@intel.com> References: <1515460747-8372-1-git-send-email-fan.wang@intel.com> Subject: [Patch 1/2] MdeModulePkg: Fixed two issues when error occurs in Mtftp4Start. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Jan 2018 01:14:03 -0000 * This function sets returned status as token status and signal token when error occurs, and it results token status not compliance with spec definition. This patch fixed this issue. * This function restore Tpl twice when Mtftp4WrqStart() returns an error, this patch fixed this issue. Cc: Jiaxin Wu Cc: Ye Ting Cc: Fu Siyuan Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Wang Fan --- .../Universal/Network/Mtftp4Dxe/Mtftp4Impl.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.c b/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.c index 54384e1..f5f9e6d 100644 --- a/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.c +++ b/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.c @@ -1,10 +1,10 @@ /** @file Interface routine for Mtftp4. (C) Copyright 2014 Hewlett-Packard Development Company, L.P.
-Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php
@@ -407,31 +407,33 @@ Mtftp4Start ( if (EFI_ERROR (Status)) { gBS->RestoreTPL (OldTpl); return Status; } + if ((Token->OverrideData != NULL) && !Mtftp4OverrideValid (Instance, Token->OverrideData)) { + Status = EFI_INVALID_PARAMETER; + gBS->RestoreTPL (OldTpl); + return Status; + } + // // Set the Operation now to prevent the application start other // operations. // Instance->Operation = Operation; Override = Token->OverrideData; - if ((Override != NULL) && !Mtftp4OverrideValid (Instance, Override)) { - Status = EFI_INVALID_PARAMETER; - goto ON_ERROR; - } - if (Token->OptionCount != 0) { Status = Mtftp4ParseOption ( Token->OptionList, Token->OptionCount, TRUE, &Instance->RequestOption ); if (EFI_ERROR (Status)) { + Status = EFI_DEVICE_ERROR; goto ON_ERROR; } } // @@ -482,10 +484,11 @@ Mtftp4Start ( // Config the unicast UDP child to send initial request // Status = Mtftp4ConfigUnicastPort (Instance->UnicastPort, Instance); if (EFI_ERROR (Status)) { + Status = EFI_DEVICE_ERROR; goto ON_ERROR; } // // Set initial status. @@ -499,17 +502,17 @@ Mtftp4Start ( Status = Mtftp4WrqStart (Instance, Operation); } else { Status = Mtftp4RrqStart (Instance, Operation); } - gBS->RestoreTPL (OldTpl); - if (EFI_ERROR (Status)) { + Status = EFI_DEVICE_ERROR; goto ON_ERROR; } if (Token->Event != NULL) { + gBS->RestoreTPL (OldTpl); return EFI_SUCCESS; } // // Return immediately for asynchronous operation or poll the @@ -517,10 +520,11 @@ Mtftp4Start ( // while (Token->Status == EFI_NOT_READY) { This->Poll (This); } + gBS->RestoreTPL (OldTpl); return Token->Status; ON_ERROR: Mtftp4CleanOperation (Instance, Status); gBS->RestoreTPL (OldTpl); -- 1.9.5.msysgit.1