From: Wang Fan Date: Mon, 8 Jan 2018 05:14:43 +0000 (+0800) Subject: MdeModulePkg: Fixed two issues when error occurs in Mtftp4Start. X-Git-Tag: edk2-stable201903~2650 X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=commitdiff_plain;h=39b0867d836292be0ffaffd2cc1edb7049c9fddd MdeModulePkg: Fixed two issues when error occurs in Mtftp4Start. * 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 Reviewed-by: Fu Siyuan Reviewed-by: Jiaxin Wu --- diff --git a/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.c b/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.c index 54384e143e..f5f9e6d8f7 100644 --- a/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.c +++ b/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.c @@ -2,7 +2,7 @@ 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 @@ -409,6 +409,12 @@ Mtftp4Start ( 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. @@ -416,11 +422,6 @@ Mtftp4Start ( 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, @@ -430,6 +431,7 @@ Mtftp4Start ( ); if (EFI_ERROR (Status)) { + Status = EFI_DEVICE_ERROR; goto ON_ERROR; } } @@ -484,6 +486,7 @@ Mtftp4Start ( Status = Mtftp4ConfigUnicastPort (Instance->UnicastPort, Instance); if (EFI_ERROR (Status)) { + Status = EFI_DEVICE_ERROR; goto ON_ERROR; } @@ -501,13 +504,13 @@ Mtftp4Start ( 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; } @@ -519,6 +522,7 @@ Mtftp4Start ( This->Poll (This); } + gBS->RestoreTPL (OldTpl); return Token->Status; ON_ERROR: