/** @file\r
The entry point of IScsi driver.\r
\r
-Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.<BR>\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
which accompanies this distribution. The full text of the license may be found at\r
//\r
// Check any AIP instances exist in system.\r
//\r
- AipHandleCount = 0;\r
+ AipHandleCount = 0;\r
+ AipHandleBuffer = NULL;\r
Status = gBS->LocateHandleBuffer (\r
ByProtocol,\r
&gEfiAdapterInformationProtocolGuid,\r
return EFI_NOT_FOUND;\r
}\r
\r
+ ASSERT (AipHandleBuffer != NULL);\r
+\r
InfoBlock = NULL;\r
\r
for (AipIndex = 0; AipIndex < AipHandleCount; AipIndex++) {\r
@retval EFI_INVALID_PARAMETER Any input parameter is invalid.\r
@retval EFI_NOT_FOUND There is no sufficient information to establish\r
the iScsi session.\r
- @retval EFI_DEVICE_ERROR Failed to get TCP connection device path. \r
+ @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.\r
+ @retval EFI_DEVICE_ERROR Failed to get TCP connection device path.\r
+ @retval EFI_ACCESS_DENIED The protocol could not be removed from the Handle\r
+ because its interfaces are being used.\r
\r
**/\r
EFI_STATUS\r
Session->ConfigData = AttemptConfigData;\r
Session->AuthType = AttemptConfigData->AuthenticationType;\r
\r
- AsciiStrToUnicodeStr (AttemptConfigData->MacString, MacString);\r
+ AsciiStrToUnicodeStrS (AttemptConfigData->MacString, MacString, sizeof (MacString) / sizeof (MacString[0]));\r
UnicodeSPrint (\r
mPrivate->PortString,\r
(UINTN) ISCSI_NAME_IFR_MAX_SIZE,\r
IScsiSessionAbort (ExistPrivate->Session);\r
}\r
\r
- IScsiCleanDriverData (ExistPrivate);\r
+ if (ExistPrivate->DevicePath != NULL) {\r
+ Status = gBS->UninstallProtocolInterface (\r
+ ExistPrivate->ExtScsiPassThruHandle,\r
+ &gEfiDevicePathProtocolGuid,\r
+ ExistPrivate->DevicePath\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ goto ON_ERROR;\r
+ }\r
+\r
+ FreePool (ExistPrivate->DevicePath);\r
+ }\r
+\r
+ gBS->CloseEvent (ExistPrivate->ExitBootServiceEvent);\r
+ FreePool (ExistPrivate);\r
+\r
}\r
} else {\r
//\r
\r
@retval EFI_SUCCESS The device was stopped.\r
@retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.\r
+ @retval EFI_INVALID_PARAMETER Child handle is NULL.\r
+ @retval EFI_ACCESS_DENIED The protocol could not be removed from the Handle\r
+ because its interfaces are being used.\r
\r
**/\r
EFI_STATUS\r
IScsiSessionAbort (Private->Session);\r
}\r
\r
- IScsiCleanDriverData (Private);\r
+ Status = IScsiCleanDriverData (Private);\r
+\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
\r
return EFI_SUCCESS;\r
}\r