[edk2] [Patch] NetworkPkg/IScsiDxe: Fix the incorrect error handling in DriverEntryPoint

Jiaxin Wu posted 1 patch 7 years ago
Failed in applying to current master (apply log)
NetworkPkg/IScsiDxe/IScsiDriver.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
[edk2] [Patch] NetworkPkg/IScsiDxe: Fix the incorrect error handling in DriverEntryPoint
Posted by Jiaxin Wu 7 years ago
Currently, error handling in IScsiDriverEntryPoint is incorrect. For
example, if IScsiCreateAttempts() return error due to the limited max
variable size, iSCSI will not unload the configuration entries.

Cc: Zhang Lubo <lubo.zhang@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: Wu Jiaxin <jiaxin.wu@intel.com>
---
 NetworkPkg/IScsiDxe/IScsiDriver.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/NetworkPkg/IScsiDxe/IScsiDriver.c b/NetworkPkg/IScsiDxe/IScsiDriver.c
index 269c1ae..2249919 100644
--- a/NetworkPkg/IScsiDxe/IScsiDriver.c
+++ b/NetworkPkg/IScsiDxe/IScsiDriver.c
@@ -1811,11 +1811,11 @@ IScsiDriverEntryPoint (
   //
   // Create Keywords for all the Attempts.
   //
   Status = IScsiCreateKeywords (PcdGet8 (PcdMaxIScsiAttemptNumber));
   if (EFI_ERROR (Status)) {
-    goto Error5;
+    goto Error6;
   }
 
   //
   // There should be only one EFI_AUTHENTICATION_INFO_PROTOCOL. If already exists,
   // do not produce the protocol instance.
@@ -1838,17 +1838,20 @@ IScsiDriverEntryPoint (
   }
 
   return EFI_SUCCESS;
 
 Error6:
-  IScsiConfigFormUnload (gIScsiIp4DriverBinding.DriverBindingHandle);
+  IScsiCleanAttemptVariable ();
 
 Error5:
-  IScsiCleanAttemptVariable ();
+  IScsiConfigFormUnload (gIScsiIp4DriverBinding.DriverBindingHandle);
 
 Error4:
-  FreePool (mPrivate);
+  if (mPrivate != NULL) {
+    FreePool (mPrivate);
+    mPrivate = NULL;
+  }
 
 Error3:
   gBS->UninstallMultipleProtocolInterfaces (
          ImageHandle,
          &gEfiIScsiInitiatorNameProtocolGuid,
-- 
1.9.5.msysgit.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
Re: [edk2] [Patch] NetworkPkg/IScsiDxe: Fix the incorrect error handling in DriverEntryPoint
Posted by Zhang, Lubo 7 years ago
Reviewed-by: Zhang Lubo <lubo.zhang@intel.com>

> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Jiaxin
> Wu
> Sent: Wednesday, March 22, 2017 9:33 AM
> To: edk2-devel@lists.01.org
> Cc: Ye, Ting <ting.ye@intel.com>; Zhang, Lubo <lubo.zhang@intel.com>; Fu,
> Siyuan <siyuan.fu@intel.com>; Wu, Jiaxin <jiaxin.wu@intel.com>
> Subject: [edk2] [Patch] NetworkPkg/IScsiDxe: Fix the incorrect error handling in
> DriverEntryPoint
> 
> Currently, error handling in IScsiDriverEntryPoint is incorrect. For example, if
> IScsiCreateAttempts() return error due to the limited max variable size, iSCSI will
> not unload the configuration entries.
> 
> Cc: Zhang Lubo <lubo.zhang@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: Wu Jiaxin <jiaxin.wu@intel.com>
> ---
>  NetworkPkg/IScsiDxe/IScsiDriver.c | 11 +++++++----
>  1 file changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/NetworkPkg/IScsiDxe/IScsiDriver.c
> b/NetworkPkg/IScsiDxe/IScsiDriver.c
> index 269c1ae..2249919 100644
> --- a/NetworkPkg/IScsiDxe/IScsiDriver.c
> +++ b/NetworkPkg/IScsiDxe/IScsiDriver.c
> @@ -1811,11 +1811,11 @@ IScsiDriverEntryPoint (
>    //
>    // Create Keywords for all the Attempts.
>    //
>    Status = IScsiCreateKeywords (PcdGet8 (PcdMaxIScsiAttemptNumber));
>    if (EFI_ERROR (Status)) {
> -    goto Error5;
> +    goto Error6;
>    }
> 
>    //
>    // There should be only one EFI_AUTHENTICATION_INFO_PROTOCOL. If
> already exists,
>    // do not produce the protocol instance.
> @@ -1838,17 +1838,20 @@ IScsiDriverEntryPoint (
>    }
> 
>    return EFI_SUCCESS;
> 
>  Error6:
> -  IScsiConfigFormUnload (gIScsiIp4DriverBinding.DriverBindingHandle);
> +  IScsiCleanAttemptVariable ();
> 
>  Error5:
> -  IScsiCleanAttemptVariable ();
> +  IScsiConfigFormUnload (gIScsiIp4DriverBinding.DriverBindingHandle);
> 
>  Error4:
> -  FreePool (mPrivate);
> +  if (mPrivate != NULL) {
> +    FreePool (mPrivate);
> +    mPrivate = NULL;
> +  }
> 
>  Error3:
>    gBS->UninstallMultipleProtocolInterfaces (
>           ImageHandle,
>           &gEfiIScsiInitiatorNameProtocolGuid,
> --
> 1.9.5.msysgit.1
> 
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel