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

2017-03-21 Thread Zhang, Lubo
Reviewed-by: Zhang Lubo 

> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@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 ; Zhang, Lubo ; Fu,
> Siyuan ; Wu, Jiaxin 
> 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 
> Cc: Ye Ting 
> Cc: Fu Siyuan 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Wu Jiaxin 
> ---
>  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


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

2017-03-21 Thread Jiaxin Wu
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 
Cc: Ye Ting 
Cc: Fu Siyuan 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
---
 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