public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [Patch 0/2] Fixed some issues in Mtftp4Dxe
@ 2018-01-09  1:19 Wang Fan
  2018-01-09  1:19 ` [Patch 1/2] MdeModulePkg: Fixed two issues when error occurs in Mtftp4Start Wang Fan
  2018-01-09  1:19 ` [Patch 2/2] MdeModulePkg: Freed packet buffer when error occurs to avoid memory leak Wang Fan
  0 siblings, 2 replies; 7+ messages in thread
From: Wang Fan @ 2018-01-09  1:19 UTC (permalink / raw)
  To: edk2-devel

See descriptions in each patch.

Wang Fan (2):
  MdeModulePkg: Fixed two issues when error occurs in Mtftp4Start.
  MdeModulePkg: Freed packet buffer when error occurs to avoid memory
    leak.

 .../Universal/Network/Mtftp4Dxe/Mtftp4Impl.c         | 20 ++++++++++++--------
 MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Wrq.c |  6 +++++-
 2 files changed, 17 insertions(+), 9 deletions(-)

-- 
1.9.5.msysgit.1



^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Patch 1/2] MdeModulePkg: Fixed two issues when error occurs in Mtftp4Start.
  2018-01-09  1:19 [Patch 0/2] Fixed some issues in Mtftp4Dxe Wang Fan
@ 2018-01-09  1:19 ` Wang Fan
  2018-01-09  1:26   ` Wu, Jiaxin
  2018-01-09  6:58   ` Fu, Siyuan
  2018-01-09  1:19 ` [Patch 2/2] MdeModulePkg: Freed packet buffer when error occurs to avoid memory leak Wang Fan
  1 sibling, 2 replies; 7+ messages in thread
From: Wang Fan @ 2018-01-09  1:19 UTC (permalink / raw)
  To: edk2-devel; +Cc: Jiaxin Wu, Ye Ting, Fu Siyuan

* 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>
---
 .../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.<BR>
-Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
 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<BR>
 
@@ -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



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [Patch 2/2] MdeModulePkg: Freed packet buffer when error occurs to avoid memory leak.
  2018-01-09  1:19 [Patch 0/2] Fixed some issues in Mtftp4Dxe Wang Fan
  2018-01-09  1:19 ` [Patch 1/2] MdeModulePkg: Fixed two issues when error occurs in Mtftp4Start Wang Fan
@ 2018-01-09  1:19 ` Wang Fan
  2018-01-09  1:27   ` Wu, Jiaxin
  2018-01-09  2:32   ` Fu, Siyuan
  1 sibling, 2 replies; 7+ messages in thread
From: Wang Fan @ 2018-01-09  1:19 UTC (permalink / raw)
  To: edk2-devel; +Cc: Jiaxin Wu, Ye Ting, Fu Siyuan

* In function Mtftp4WrqSendBlock(), when packet is not needed, function
  returns EFI_ABORTED but not freed the packet buffer. It results some
  memory leak and this patch is to fix 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>
---
 MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Wrq.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Wrq.c b/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Wrq.c
index e825714..438659a 100644
--- a/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Wrq.c
+++ b/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Wrq.c
@@ -1,9 +1,9 @@
 /** @file
   Routines to process Wrq (upload).
   
-Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
 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<BR>
 
@@ -92,10 +92,14 @@ Mtftp4WrqSendBlock (
     if (EFI_ERROR (Status) || (DataLen > Instance->BlkSize)) {
       if (DataBuf != NULL) {
         FreePool (DataBuf);
       }
 
+      if (UdpPacket != NULL) {
+        NetbufFree (UdpPacket);
+      }
+
       Mtftp4SendError (
         Instance,
         EFI_MTFTP4_ERRORCODE_REQUEST_DENIED,
         (UINT8 *) "User aborted the transfer"
         );
-- 
1.9.5.msysgit.1



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [Patch 1/2] MdeModulePkg: Fixed two issues when error occurs in Mtftp4Start.
  2018-01-09  1:19 ` [Patch 1/2] MdeModulePkg: Fixed two issues when error occurs in Mtftp4Start Wang Fan
@ 2018-01-09  1:26   ` Wu, Jiaxin
  2018-01-09  6:58   ` Fu, Siyuan
  1 sibling, 0 replies; 7+ messages in thread
From: Wu, Jiaxin @ 2018-01-09  1:26 UTC (permalink / raw)
  To: Wang, Fan, edk2-devel@lists.01.org; +Cc: Ye, Ting, Fu, Siyuan

Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>


> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of
> Wang Fan
> Sent: Tuesday, January 9, 2018 9:19 AM
> To: edk2-devel@lists.01.org
> Cc: Ye, Ting <ting.ye@intel.com>; Fu, Siyuan <siyuan.fu@intel.com>; Wu,
> Jiaxin <jiaxin.wu@intel.com>
> Subject: [edk2] [Patch 1/2] 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 <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>
> ---
>  .../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.<BR>
> -Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>
> +Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
>  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<BR>
> 
> @@ -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
> 
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Patch 2/2] MdeModulePkg: Freed packet buffer when error occurs to avoid memory leak.
  2018-01-09  1:19 ` [Patch 2/2] MdeModulePkg: Freed packet buffer when error occurs to avoid memory leak Wang Fan
@ 2018-01-09  1:27   ` Wu, Jiaxin
  2018-01-09  2:32   ` Fu, Siyuan
  1 sibling, 0 replies; 7+ messages in thread
From: Wu, Jiaxin @ 2018-01-09  1:27 UTC (permalink / raw)
  To: Wang, Fan, edk2-devel@lists.01.org; +Cc: Ye, Ting, Fu, Siyuan

Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>


> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of
> Wang Fan
> Sent: Tuesday, January 9, 2018 9:19 AM
> To: edk2-devel@lists.01.org
> Cc: Ye, Ting <ting.ye@intel.com>; Fu, Siyuan <siyuan.fu@intel.com>; Wu,
> Jiaxin <jiaxin.wu@intel.com>
> Subject: [edk2] [Patch 2/2] MdeModulePkg: Freed packet buffer when error
> occurs to avoid memory leak.
> 
> * In function Mtftp4WrqSendBlock(), when packet is not needed, function
>   returns EFI_ABORTED but not freed the packet buffer. It results some
>   memory leak and this patch is to fix 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>
> ---
>  MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Wrq.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Wrq.c
> b/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Wrq.c
> index e825714..438659a 100644
> --- a/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Wrq.c
> +++ b/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Wrq.c
> @@ -1,9 +1,9 @@
>  /** @file
>    Routines to process Wrq (upload).
> 
> -Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
> +Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
>  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<BR>
> 
> @@ -92,10 +92,14 @@ Mtftp4WrqSendBlock (
>      if (EFI_ERROR (Status) || (DataLen > Instance->BlkSize)) {
>        if (DataBuf != NULL) {
>          FreePool (DataBuf);
>        }
> 
> +      if (UdpPacket != NULL) {
> +        NetbufFree (UdpPacket);
> +      }
> +
>        Mtftp4SendError (
>          Instance,
>          EFI_MTFTP4_ERRORCODE_REQUEST_DENIED,
>          (UINT8 *) "User aborted the transfer"
>          );
> --
> 1.9.5.msysgit.1
> 
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Patch 2/2] MdeModulePkg: Freed packet buffer when error occurs to avoid memory leak.
  2018-01-09  1:19 ` [Patch 2/2] MdeModulePkg: Freed packet buffer when error occurs to avoid memory leak Wang Fan
  2018-01-09  1:27   ` Wu, Jiaxin
@ 2018-01-09  2:32   ` Fu, Siyuan
  1 sibling, 0 replies; 7+ messages in thread
From: Fu, Siyuan @ 2018-01-09  2:32 UTC (permalink / raw)
  To: Wang, Fan, edk2-devel@lists.01.org; +Cc: Ye, Ting, Wu, Jiaxin



Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>



> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of
> Wang Fan
> Sent: Tuesday, January 9, 2018 9:19 AM
> To: edk2-devel@lists.01.org
> Cc: Ye, Ting <ting.ye@intel.com>; Fu, Siyuan <siyuan.fu@intel.com>; Wu,
> Jiaxin <jiaxin.wu@intel.com>
> Subject: [edk2] [Patch 2/2] MdeModulePkg: Freed packet buffer when error
> occurs to avoid memory leak.
> 
> * In function Mtftp4WrqSendBlock(), when packet is not needed, function
>   returns EFI_ABORTED but not freed the packet buffer. It results some
>   memory leak and this patch is to fix 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>
> ---
>  MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Wrq.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Wrq.c
> b/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Wrq.c
> index e825714..438659a 100644
> --- a/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Wrq.c
> +++ b/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Wrq.c
> @@ -1,9 +1,9 @@
>  /** @file
>    Routines to process Wrq (upload).
> 
> -Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
> +Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
>  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<BR>
> 
> @@ -92,10 +92,14 @@ Mtftp4WrqSendBlock (
>      if (EFI_ERROR (Status) || (DataLen > Instance->BlkSize)) {
>        if (DataBuf != NULL) {
>          FreePool (DataBuf);
>        }
> 
> +      if (UdpPacket != NULL) {
> +        NetbufFree (UdpPacket);
> +      }
> +
>        Mtftp4SendError (
>          Instance,
>          EFI_MTFTP4_ERRORCODE_REQUEST_DENIED,
>          (UINT8 *) "User aborted the transfer"
>          );
> --
> 1.9.5.msysgit.1
> 
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Patch 1/2] MdeModulePkg: Fixed two issues when error occurs in Mtftp4Start.
  2018-01-09  1:19 ` [Patch 1/2] MdeModulePkg: Fixed two issues when error occurs in Mtftp4Start Wang Fan
  2018-01-09  1:26   ` Wu, Jiaxin
@ 2018-01-09  6:58   ` Fu, Siyuan
  1 sibling, 0 replies; 7+ messages in thread
From: Fu, Siyuan @ 2018-01-09  6:58 UTC (permalink / raw)
  To: Wang, Fan, edk2-devel@lists.01.org; +Cc: Wu, Jiaxin, Ye, Ting

Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>

> -----Original Message-----
> From: Wang, Fan
> Sent: Tuesday, January 9, 2018 9:19 AM
> To: edk2-devel@lists.01.org
> Cc: Wu, Jiaxin <jiaxin.wu@intel.com>; Ye, Ting <ting.ye@intel.com>; Fu,
> Siyuan <siyuan.fu@intel.com>
> Subject: [Patch 1/2] 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 <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>
> ---
>  .../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.<BR>
> -Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>
> +Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
>  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<BR>
> 
> @@ -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



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-01-09  6:53 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-09  1:19 [Patch 0/2] Fixed some issues in Mtftp4Dxe Wang Fan
2018-01-09  1:19 ` [Patch 1/2] MdeModulePkg: Fixed two issues when error occurs in Mtftp4Start Wang Fan
2018-01-09  1:26   ` Wu, Jiaxin
2018-01-09  6:58   ` Fu, Siyuan
2018-01-09  1:19 ` [Patch 2/2] MdeModulePkg: Freed packet buffer when error occurs to avoid memory leak Wang Fan
2018-01-09  1:27   ` Wu, Jiaxin
2018-01-09  2:32   ` Fu, Siyuan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox