summaryrefslogtreecommitdiffstats
path: root/NetworkPkg/IScsiDxe/IScsiDriver.c
diff options
context:
space:
mode:
authorFu Siyuan <siyuan.fu@intel.com>2014-01-10 08:24:29 +0000
committersfu5 <sfu5@6f19259b-4bc3-4df7-8a09-765794883524>2014-01-10 08:24:29 +0000
commit18b24f924f06f2345c0410d145d14e1a9a500dc8 (patch)
tree3022f6cdbe1070be66bef76bb2e5d05aa316d33e /NetworkPkg/IScsiDxe/IScsiDriver.c
parent9325f68430361597e811f2ae2ad88a4b3440da09 (diff)
downloadedk2-18b24f924f06f2345c0410d145d14e1a9a500dc8.tar.gz
edk2-18b24f924f06f2345c0410d145d14e1a9a500dc8.tar.bz2
edk2-18b24f924f06f2345c0410d145d14e1a9a500dc8.zip
Fix bug in unload function: Check if component name protocol exist, only uninstall it when it really exists.
Signed-off-by: Fu Siyuan <siyuan.fu@intel.com> Reviewed-by: Tian, Feng <feng.tian@intel.com> Reviewed-by: Jin, Eric <eric.jin@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15092 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'NetworkPkg/IScsiDxe/IScsiDriver.c')
-rw-r--r--NetworkPkg/IScsiDxe/IScsiDriver.c216
1 files changed, 169 insertions, 47 deletions
diff --git a/NetworkPkg/IScsiDxe/IScsiDriver.c b/NetworkPkg/IScsiDxe/IScsiDriver.c
index 6d6f9a13ed..42ac8f0fe7 100644
--- a/NetworkPkg/IScsiDxe/IScsiDriver.c
+++ b/NetworkPkg/IScsiDxe/IScsiDriver.c
@@ -1,7 +1,7 @@
/** @file
The entry point of IScsi driver.
-Copyright (c) 2004 - 2013, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2014, 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
@@ -1245,10 +1245,12 @@ IScsiUnload (
IN EFI_HANDLE ImageHandle
)
{
- EFI_STATUS Status;
- UINTN DeviceHandleCount;
- EFI_HANDLE *DeviceHandleBuffer;
- UINTN Index;
+ EFI_STATUS Status;
+ UINTN DeviceHandleCount;
+ EFI_HANDLE *DeviceHandleBuffer;
+ UINTN Index;
+ EFI_COMPONENT_NAME_PROTOCOL *ComponentName;
+ EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2;
//
// Try to disonnect the driver from the devices it's controlling.
@@ -1264,64 +1266,184 @@ IScsiUnload (
return Status;
}
+ //
+ // Disconnect the iSCSI4 driver from the controlled device.
+ //
+ for (Index = 0; Index < DeviceHandleCount; Index++) {
+ Status = IScsiTestManagedDevice (
+ DeviceHandleBuffer[Index],
+ gIScsiIp4DriverBinding.DriverBindingHandle,
+ &gEfiTcp4ProtocolGuid)
+ ;
+ if (EFI_ERROR (Status)) {
+ continue;
+ }
+ Status = gBS->DisconnectController (
+ DeviceHandleBuffer[Index],
+ gIScsiIp4DriverBinding.DriverBindingHandle,
+ NULL
+ );
+ if (EFI_ERROR (Status)) {
+ goto ON_EXIT;
+ }
+ }
+
+ //
+ // Disconnect the iSCSI6 driver from the controlled device.
+ //
for (Index = 0; Index < DeviceHandleCount; Index++) {
- gBS->DisconnectController (
- DeviceHandleBuffer[Index],
+ Status = IScsiTestManagedDevice (
+ DeviceHandleBuffer[Index],
+ gIScsiIp6DriverBinding.DriverBindingHandle,
+ &gEfiTcp6ProtocolGuid
+ );
+ if (EFI_ERROR (Status)) {
+ continue;
+ }
+ Status = gBS->DisconnectController (
+ DeviceHandleBuffer[Index],
+ gIScsiIp6DriverBinding.DriverBindingHandle,
+ NULL
+ );
+ if (EFI_ERROR (Status)) {
+ goto ON_EXIT;
+ }
+ }
+
+ //
+ // Unload the iSCSI configuration form.
+ //
+ Status = IScsiConfigFormUnload (gIScsiIp4DriverBinding.DriverBindingHandle);
+ if (EFI_ERROR (Status)) {
+ goto ON_EXIT;
+ }
+
+ //
+ // Uninstall the protocols installed by iSCSI driver.
+ //
+ Status = gBS->UninstallMultipleProtocolInterfaces (
+ ImageHandle,
+ &gEfiAuthenticationInfoProtocolGuid,
+ &gIScsiAuthenticationInfo,
+ NULL
+ );
+ if (EFI_ERROR (Status)) {
+ goto ON_EXIT;
+ }
+
+ if (gIScsiControllerNameTable!= NULL) {
+ Status = FreeUnicodeStringTable (gIScsiControllerNameTable);
+ if (EFI_ERROR (Status)) {
+ goto ON_EXIT;
+ }
+ gIScsiControllerNameTable = NULL;
+ }
+
+ //
+ // Uninstall the ComponentName and ComponentName2 protocol from iSCSI4 driver binding handle
+ // if it has been installed.
+ //
+ Status = gBS->HandleProtocol (
+ gIScsiIp4DriverBinding.DriverBindingHandle,
+ &gEfiComponentNameProtocolGuid,
+ (VOID **) &ComponentName
+ );
+ if (!EFI_ERROR (Status)) {
+ Status = gBS->UninstallMultipleProtocolInterfaces (
gIScsiIp4DriverBinding.DriverBindingHandle,
+ &gEfiComponentNameProtocolGuid,
+ ComponentName,
NULL
);
- gBS->DisconnectController (
- DeviceHandleBuffer[Index],
- gIScsiIp6DriverBinding.DriverBindingHandle,
+ if (EFI_ERROR (Status)) {
+ goto ON_EXIT;
+ }
+ }
+
+ Status = gBS->HandleProtocol (
+ gIScsiIp4DriverBinding.DriverBindingHandle,
+ &gEfiComponentName2ProtocolGuid,
+ (VOID **) &ComponentName2
+ );
+ if (!EFI_ERROR (Status)) {
+ gBS->UninstallMultipleProtocolInterfaces (
+ gIScsiIp4DriverBinding.DriverBindingHandle,
+ &gEfiComponentName2ProtocolGuid,
+ ComponentName2,
NULL
);
+ if (EFI_ERROR (Status)) {
+ goto ON_EXIT;
+ }
}
//
- // Unload the iSCSI configuration form.
+ // Uninstall the ComponentName and ComponentName2 protocol from iSCSI6 driver binding handle
+ // if it has been installed.
//
- IScsiConfigFormUnload (gIScsiIp4DriverBinding.DriverBindingHandle);
+ Status = gBS->HandleProtocol (
+ gIScsiIp6DriverBinding.DriverBindingHandle,
+ &gEfiComponentNameProtocolGuid,
+ (VOID **) &ComponentName
+ );
+ if (!EFI_ERROR (Status)) {
+ Status = gBS->UninstallMultipleProtocolInterfaces (
+ gIScsiIp6DriverBinding.DriverBindingHandle,
+ &gEfiComponentNameProtocolGuid,
+ ComponentName,
+ NULL
+ );
+ if (EFI_ERROR (Status)) {
+ goto ON_EXIT;
+ }
+ }
+
+ Status = gBS->HandleProtocol (
+ gIScsiIp6DriverBinding.DriverBindingHandle,
+ &gEfiComponentName2ProtocolGuid,
+ (VOID **) &ComponentName2
+ );
+ if (!EFI_ERROR (Status)) {
+ gBS->UninstallMultipleProtocolInterfaces (
+ gIScsiIp6DriverBinding.DriverBindingHandle,
+ &gEfiComponentName2ProtocolGuid,
+ ComponentName2,
+ NULL
+ );
+ if (EFI_ERROR (Status)) {
+ goto ON_EXIT;
+ }
+ }
//
- // Uninstall the protocols installed by iSCSI driver.
+ // Uninstall the IScsiInitiatorNameProtocol and all the driver binding protocols.
//
- gBS->UninstallMultipleProtocolInterfaces (
- ImageHandle,
- &gEfiAuthenticationInfoProtocolGuid,
- &gIScsiAuthenticationInfo,
- NULL
- );
-
- if (gIScsiControllerNameTable!= NULL) {
- FreeUnicodeStringTable (gIScsiControllerNameTable);
- gIScsiControllerNameTable = NULL;
+ Status = gBS->UninstallMultipleProtocolInterfaces (
+ gIScsiIp4DriverBinding.DriverBindingHandle,
+ &gEfiDriverBindingProtocolGuid,
+ &gIScsiIp4DriverBinding,
+ &gEfiIScsiInitiatorNameProtocolGuid,
+ &gIScsiInitiatorName,
+ NULL
+ );
+ if (EFI_ERROR (Status)) {
+ goto ON_EXIT;
}
-
- gBS->UninstallMultipleProtocolInterfaces (
- gIScsiIp4DriverBinding.DriverBindingHandle,
- &gEfiDriverBindingProtocolGuid,
- &gIScsiIp4DriverBinding,
- &gEfiComponentName2ProtocolGuid,
- &gIScsiComponentName2,
- &gEfiComponentNameProtocolGuid,
- &gIScsiComponentName,
- &gEfiIScsiInitiatorNameProtocolGuid,
- &gIScsiInitiatorName,
- NULL
- );
- gBS->UninstallMultipleProtocolInterfaces (
- gIScsiIp6DriverBinding.DriverBindingHandle,
- &gEfiDriverBindingProtocolGuid,
- &gIScsiIp6DriverBinding,
- &gEfiComponentName2ProtocolGuid,
- &gIScsiComponentName2,
- &gEfiComponentNameProtocolGuid,
- &gIScsiComponentName,
- NULL
- );
+ Status = gBS->UninstallMultipleProtocolInterfaces (
+ gIScsiIp6DriverBinding.DriverBindingHandle,
+ &gEfiDriverBindingProtocolGuid,
+ &gIScsiIp6DriverBinding,
+ NULL
+ );
- return EFI_SUCCESS;
+ON_EXIT:
+
+ if (DeviceHandleBuffer != NULL) {
+ FreePool (DeviceHandleBuffer);
+ }
+
+ return Status;
}
/**