]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.c
MdeModulePkg: Fixed two issues when error occurs in Mtftp4Start.
[mirror_edk2.git] / 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