]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg: Fixed two issues when error occurs in Mtftp4Start.
authorWang Fan <fan.wang@intel.com>
Mon, 8 Jan 2018 05:14:43 +0000 (13:14 +0800)
committerJiaxin Wu <jiaxin.wu@intel.com>
Wed, 10 Jan 2018 00:30:18 +0000 (08:30 +0800)
* 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 <jiaxin.wu@intel.com>
Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wang Fan <fan.wang@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.c

index 54384e143e2d290668c2d6687a7bc63d38309389..f5f9e6d8f7a40a89e955c431af3eb2e072d0bfdd 100644 (file)
@@ -2,7 +2,7 @@
   Interface routine for Mtftp4.\r
   \r
 (C) Copyright 2014 Hewlett-Packard Development Company, L.P.<BR>\r
-Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -409,6 +409,12 @@ Mtftp4Start (
     return Status;\r
   }\r
 \r
+  if ((Token->OverrideData != NULL) && !Mtftp4OverrideValid (Instance, Token->OverrideData)) {\r
+    Status = EFI_INVALID_PARAMETER;\r
+    gBS->RestoreTPL (OldTpl);\r
+    return Status;\r
+  }\r
+\r
   //\r
   // Set the Operation now to prevent the application start other\r
   // operations.\r
@@ -416,11 +422,6 @@ Mtftp4Start (
   Instance->Operation = Operation;\r
   Override            = Token->OverrideData;\r
 \r
-  if ((Override != NULL) && !Mtftp4OverrideValid (Instance, Override)) {\r
-    Status = EFI_INVALID_PARAMETER;\r
-    goto ON_ERROR;\r
-  }\r
-\r
   if (Token->OptionCount != 0) {\r
     Status = Mtftp4ParseOption (\r
                Token->OptionList,\r
@@ -430,6 +431,7 @@ Mtftp4Start (
                );\r
 \r
     if (EFI_ERROR (Status)) {\r
+      Status = EFI_DEVICE_ERROR;\r
       goto ON_ERROR;\r
     }\r
   }\r
@@ -484,6 +486,7 @@ Mtftp4Start (
   Status = Mtftp4ConfigUnicastPort (Instance->UnicastPort, Instance);\r
 \r
   if (EFI_ERROR (Status)) {\r
+    Status = EFI_DEVICE_ERROR;\r
     goto ON_ERROR;\r
   }\r
 \r
@@ -501,13 +504,13 @@ Mtftp4Start (
     Status = Mtftp4RrqStart (Instance, Operation);\r
   }\r
 \r
-  gBS->RestoreTPL (OldTpl);\r
-\r
   if (EFI_ERROR (Status)) {\r
+    Status = EFI_DEVICE_ERROR;\r
     goto ON_ERROR;\r
   }\r
 \r
   if (Token->Event != NULL) {\r
+    gBS->RestoreTPL (OldTpl);\r
     return EFI_SUCCESS;\r
   }\r
 \r
@@ -519,6 +522,7 @@ Mtftp4Start (
     This->Poll (This);\r
   }\r
 \r
+  gBS->RestoreTPL (OldTpl);\r
   return Token->Status;\r
 \r
 ON_ERROR:\r