From f2a94e25589a2f79cd3e508960a5c29290aa58ea Mon Sep 17 00:00:00 2001 From: eric_tian Date: Fri, 21 Mar 2008 03:28:56 +0000 Subject: [PATCH] [Description] solve the x64 exception issue when unloading iSCSI driver [Impaction] add some handler for failure branch and prohibit the additional ISCSI INITIATOR NAME PROTOCOL from being installed. [Reference Info] this bug is reported by DELL. it causes an exception in x64 on unloading iscsi driver. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@4941 6f19259b-4bc3-4df7-8a09-765794883524 --- .../Universal/Network/IScsiDxe/IScsiConfig.c | 19 ++++--- .../Universal/Network/IScsiDxe/IScsiDriver.c | 51 ++++++++++++++----- 2 files changed, 50 insertions(+), 20 deletions(-) diff --git a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfig.c b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfig.c index 92169cb9b2..4944152111 100644 --- a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfig.c +++ b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfig.c @@ -1,6 +1,6 @@ /*++ -Copyright (c) 2004 - 2007, Intel Corporation +Copyright (c) 2004 - 2008, 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 @@ -19,10 +19,10 @@ Abstract: #include "IScsiImpl.h" -EFI_GUID mVendorGuid = ISCSI_CONFIG_GUID; -BOOLEAN mIScsiDeviceListUpdated = FALSE; -UINTN mNumberOfIScsiDevices = 0; -ISCSI_FORM_CALLBACK_INFO *mCallbackInfo; +EFI_GUID mVendorGuid = ISCSI_CONFIG_GUID; +BOOLEAN mIScsiDeviceListUpdated = FALSE; +UINTN mNumberOfIScsiDevices = 0; +ISCSI_FORM_CALLBACK_INFO *mCallbackInfo = NULL; LIST_ENTRY mIScsiConfigFormList = { &mIScsiConfigFormList, @@ -923,9 +923,9 @@ Returns: return EFI_OUT_OF_RESOURCES; } - CallbackInfo->Signature = ISCSI_FORM_CALLBACK_INFO_SIGNATURE; + CallbackInfo->Signature = ISCSI_FORM_CALLBACK_INFO_SIGNATURE; CallbackInfo->HiiDatabase = HiiDatabase; - CallbackInfo->Current = NULL; + CallbackInfo->Current = NULL; CallbackInfo->ConfigAccess.ExtractConfig = IScsiFormExtractConfig; CallbackInfo->ConfigAccess.RouteConfig = IScsiFormRouteConfig; @@ -933,6 +933,7 @@ Returns: Status = gBS->LocateProtocol (&gEfiHiiConfigRoutingProtocolGuid, NULL, (VOID **)&CallbackInfo->ConfigRouting); if (EFI_ERROR (Status)) { + FreePool(CallbackInfo); return Status; } @@ -941,6 +942,7 @@ Returns: // Status = HiiLibCreateHiiDriverHandle (&CallbackInfo->DriverHandle); if (EFI_ERROR (Status)) { + FreePool(CallbackInfo); return Status; } @@ -967,8 +969,9 @@ Returns: CallbackInfo->DriverHandle, &CallbackInfo->RegisteredHandle ); - gBS->FreePool (PackageList); + FreePool (PackageList); if (EFI_ERROR (Status)) { + FreePool(CallbackInfo); return Status; } diff --git a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiDriver.c b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiDriver.c index 8cc2a5050f..bc777e7785 100644 --- a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiDriver.c +++ b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiDriver.c @@ -1,6 +1,6 @@ /*++ -Copyright (c) 2004 - 2007, Intel Corporation +Copyright (c) 2004 - 2008, 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 @@ -413,8 +413,21 @@ Returns: --*/ { - EFI_STATUS Status; - //EFI_LOADED_IMAGE_PROTOCOL *LoadedImage; + EFI_STATUS Status; + EFI_ISCSI_INITIATOR_NAME_PROTOCOL *IScsiInitiatorName; + + // + // There should be only one EFI_ISCSI_INITIATOR_NAME_PROTOCOL. + // + Status = gBS->LocateProtocol ( + &gEfiIScsiInitiatorNameProtocolGuid, + NULL, + &IScsiInitiatorName + ); + + if (!EFI_ERROR (Status)) { + return EFI_ACCESS_DENIED; + } // // Initialize the EFI Driver Library @@ -427,12 +440,11 @@ Returns: &gIScsiComponentName, &gIScsiComponentName2 ); - - if (EFI_ERROR (Status)) { - return Status; - } if (!EFI_ERROR (Status)) { + // + // Install the iSCSI Initiator Name Protocol. + // Status = gBS->InstallProtocolInterface ( &ImageHandle, &gEfiIScsiInitiatorNameProtocolGuid, @@ -450,13 +462,28 @@ Returns: &gIScsiComponentName, NULL ); + return Status; + } + + // + // Initialize the configuration form of iSCSI. + // + Status = IScsiConfigFormInit (gIScsiDriverBinding.DriverBindingHandle); + if (EFI_ERROR (Status)) { + gBS->UninstallMultipleProtocolInterfaces ( + ImageHandle, + &gEfiDriverBindingProtocolGuid, + &gIScsiDriverBinding, + &gEfiComponentName2ProtocolGuid, + &gIScsiComponentName2, + &gEfiComponentNameProtocolGuid, + &gIScsiComponentName, + &gEfiIScsiInitiatorNameProtocolGuid, + &gIScsiInitiatorName, + NULL + ); } } - // - // Initialize the configuration form of iSCSI. - // - IScsiConfigFormInit (gIScsiDriverBinding.DriverBindingHandle); - return Status; }