From 2fa77862fd4e962c81524ffd667b62a6adbcff22 Mon Sep 17 00:00:00 2001 From: Elvin Li Date: Thu, 9 Jan 2014 08:47:03 +0000 Subject: [PATCH] If the driver does not start before, we do not disconnect driver and we must still uninstall other protocols on image handle. The original implementation of error return is not correct. Signed-off-by: Elvin Li Reviewed-by: Feng Tian git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15069 6f19259b-4bc3-4df7-8a09-765794883524 --- MdeModulePkg/Bus/I2c/I2cDxe/I2cBus.c | 30 +++++++++++++-------------- MdeModulePkg/Bus/I2c/I2cDxe/I2cHost.c | 30 +++++++++++++-------------- 2 files changed, 28 insertions(+), 32 deletions(-) diff --git a/MdeModulePkg/Bus/I2c/I2cDxe/I2cBus.c b/MdeModulePkg/Bus/I2c/I2cDxe/I2cBus.c index 02c3a0e353..c9913c07ca 100644 --- a/MdeModulePkg/Bus/I2c/I2cDxe/I2cBus.c +++ b/MdeModulePkg/Bus/I2c/I2cDxe/I2cBus.c @@ -1424,22 +1424,20 @@ I2cBusUnload ( &DeviceHandleBuffer ); - if (EFI_ERROR (Status)) { - return Status; - } - - // - // Disconnect the driver specified by Driver BindingHandle from all - // the devices in the handle database. - // - for (Index = 0; Index < DeviceHandleCount; Index++) { - Status = gBS->DisconnectController ( - DeviceHandleBuffer[Index], - gI2cBusDriverBinding.DriverBindingHandle, - NULL - ); - if (EFI_ERROR (Status)) { - goto Done; + if (!EFI_ERROR (Status)) { + // + // Disconnect the driver specified by Driver BindingHandle from all + // the devices in the handle database. + // + for (Index = 0; Index < DeviceHandleCount; Index++) { + Status = gBS->DisconnectController ( + DeviceHandleBuffer[Index], + gI2cBusDriverBinding.DriverBindingHandle, + NULL + ); + if (EFI_ERROR (Status)) { + goto Done; + } } } diff --git a/MdeModulePkg/Bus/I2c/I2cDxe/I2cHost.c b/MdeModulePkg/Bus/I2c/I2cDxe/I2cHost.c index 80314d0660..0cc8e33842 100644 --- a/MdeModulePkg/Bus/I2c/I2cDxe/I2cHost.c +++ b/MdeModulePkg/Bus/I2c/I2cDxe/I2cHost.c @@ -1147,22 +1147,20 @@ I2cHostUnload ( &DeviceHandleBuffer ); - if (EFI_ERROR (Status)) { - return Status; - } - - // - // Disconnect the driver specified by ImageHandle from all - // the devices in the handle database. - // - for (Index = 0; Index < DeviceHandleCount; Index++) { - Status = gBS->DisconnectController ( - DeviceHandleBuffer[Index], - ImageHandle, - NULL - ); - if (EFI_ERROR (Status)) { - goto Done; + if (!EFI_ERROR (Status)) { + // + // Disconnect the driver specified by ImageHandle from all + // the devices in the handle database. + // + for (Index = 0; Index < DeviceHandleCount; Index++) { + Status = gBS->DisconnectController ( + DeviceHandleBuffer[Index], + ImageHandle, + NULL + ); + if (EFI_ERROR (Status)) { + goto Done; + } } } -- 2.39.2