From e590d29f6e10d73d531e349e33dd28173cc076bf Mon Sep 17 00:00:00 2001 From: Zhang Lubo Date: Fri, 22 Apr 2016 15:18:56 +0800 Subject: NetworkPkg: refine codes of iSCSI driver. Add error handling logic in DriverBingingStop function, it may return error status when invoking the UninstallProtocolInterface. Cc: Fu Siyuan Cc: Ye Ting Cc: Wu Jiaxin Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Zhang Lubo Reviewed-by: Ye Ting Reviewed-by: Fu Siyuan Reviewed-by: Jiaxin Wu --- NetworkPkg/IScsiDxe/IScsiDriver.c | 20 ++++++++++++++++---- NetworkPkg/IScsiDxe/IScsiMisc.c | 25 +++++++++++++++++-------- NetworkPkg/IScsiDxe/IScsiMisc.h | 9 ++++++--- 3 files changed, 39 insertions(+), 15 deletions(-) (limited to 'NetworkPkg/IScsiDxe') diff --git a/NetworkPkg/IScsiDxe/IScsiDriver.c b/NetworkPkg/IScsiDxe/IScsiDriver.c index 51ce16911b..12095cb3ff 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 - 2015, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2016, 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 @@ -323,7 +323,9 @@ IScsiSupported ( @retval EFI_INVALID_PARAMETER Any input parameter is invalid. @retval EFI_NOT_FOUND There is no sufficient information to establish the iScsi session. - @retval EFI_DEVICE_ERROR Failed to get TCP connection device path. + @retval EFI_DEVICE_ERROR Failed to get TCP connection device path. + @retval EFI_ACCESS_DENIED The protocol could not be removed from the Handle + because its interfaces are being used. **/ EFI_STATUS @@ -863,7 +865,10 @@ IScsiStart ( IScsiSessionAbort (ExistPrivate->Session); } - IScsiCleanDriverData (ExistPrivate); + Status = IScsiCleanDriverData (ExistPrivate); + if (EFI_ERROR (Status)) { + goto ON_ERROR; + } } } else { // @@ -963,6 +968,9 @@ ON_ERROR: @retval EFI_SUCCESS The device was stopped. @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error. + @retval EFI_INVALID_PARAMETER Child handle is NULL. + @retval EFI_ACCESS_DENIED The protocol could not be removed from the Handle + because its interfaces are being used. **/ EFI_STATUS @@ -1105,7 +1113,11 @@ IScsiStop ( IScsiSessionAbort (Private->Session); } - IScsiCleanDriverData (Private); + Status = IScsiCleanDriverData (Private); + + if (EFI_ERROR (Status)) { + return Status; + } return EFI_SUCCESS; } diff --git a/NetworkPkg/IScsiDxe/IScsiMisc.c b/NetworkPkg/IScsiDxe/IScsiMisc.c index 5fc25a0df0..24067179c9 100644 --- a/NetworkPkg/IScsiDxe/IScsiMisc.c +++ b/NetworkPkg/IScsiDxe/IScsiMisc.c @@ -1,7 +1,7 @@ /** @file Miscellaneous routines for iSCSI driver. -Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2016, 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 @@ -857,10 +857,13 @@ IScsiCreateDriverData ( /** Clean the iSCSI driver data. - @param[in] Private The iSCSI driver data. + @param[in] Private The iSCSI driver data. + + @retval EFI_SUCCES The clean operation is successful. + @retval Others Other errors as indicated. **/ -VOID +EFI_STATUS IScsiCleanDriverData ( IN ISCSI_DRIVER_DATA *Private ) @@ -868,11 +871,14 @@ IScsiCleanDriverData ( EFI_STATUS Status; if (Private->DevicePath != NULL) { - gBS->UninstallProtocolInterface ( - Private->ExtScsiPassThruHandle, - &gEfiDevicePathProtocolGuid, - Private->DevicePath - ); + Status = gBS->UninstallProtocolInterface ( + Private->ExtScsiPassThruHandle, + &gEfiDevicePathProtocolGuid, + Private->DevicePath + ); + if (EFI_ERROR (Status)) { + goto EXIT; + } FreePool (Private->DevicePath); } @@ -888,9 +894,12 @@ IScsiCleanDriverData ( } } +EXIT: + gBS->CloseEvent (Private->ExitBootServiceEvent); FreePool (Private); + return Status; } /** diff --git a/NetworkPkg/IScsiDxe/IScsiMisc.h b/NetworkPkg/IScsiDxe/IScsiMisc.h index 7c7a6ba4e0..1bcaeb8bcc 100644 --- a/NetworkPkg/IScsiDxe/IScsiMisc.h +++ b/NetworkPkg/IScsiDxe/IScsiMisc.h @@ -1,7 +1,7 @@ /** @file Miscellaneous definitions for iSCSI driver. -Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2016, 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 @@ -306,10 +306,13 @@ IScsiCreateDriverData ( /** Clean the iSCSI driver data. - @param[in] Private The iSCSI driver data. + @param[in] Private The iSCSI driver data. + + @retval EFI_SUCCES The clean operation is successful. + @retval Others Other errors as indicated. **/ -VOID +EFI_STATUS IScsiCleanDriverData ( IN ISCSI_DRIVER_DATA *Private ); -- cgit v1.2.3