diff options
author | Ruiyu Ni <ruiyu.ni@intel.com> | 2014-01-09 08:59:24 +0000 |
---|---|---|
committer | Jordan Justen <jordan.l.justen@intel.com> | 2016-04-06 23:22:43 -0700 |
commit | b6efb80ad0fe5c3fd89484afd9a057532630b114 (patch) | |
tree | 990e3ac8e41b5df13ac80766a019e2d13a666324 /FatPkg | |
parent | bd10d0712fe2c644c00af6e3d2d968587ea0c400 (diff) | |
download | edk2-b6efb80ad0fe5c3fd89484afd9a057532630b114.tar.gz edk2-b6efb80ad0fe5c3fd89484afd9a057532630b114.tar.bz2 edk2-b6efb80ad0fe5c3fd89484afd9a057532630b114.zip |
Fix a bug that prevents Fat driver being unloaded successfully.
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Feng Tian <feng.tian@intel.com>
(based on FatPkg commit 8e0e11897d92c75a6cd1d0fa8af8cb50a60bfe2d)
[jordan.l.justen@intel.com: Use script to relicense to 2-clause BSD]
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Acked-by: Mark Doran <mark.doran@intel.com>
Acked-by: Laszlo Ersek <lersek@redhat.com>
Diffstat (limited to 'FatPkg')
-rw-r--r-- | FatPkg/EnhancedFatDxe/Fat.c | 69 |
1 files changed, 64 insertions, 5 deletions
diff --git a/FatPkg/EnhancedFatDxe/Fat.c b/FatPkg/EnhancedFatDxe/Fat.c index 0dcb3bcb43..2080005adc 100644 --- a/FatPkg/EnhancedFatDxe/Fat.c +++ b/FatPkg/EnhancedFatDxe/Fat.c @@ -1,6 +1,6 @@ /*++
-Copyright (c) 2005 - 2013, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2005 - 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
@@ -140,6 +140,8 @@ Returns: EFI_HANDLE *DeviceHandleBuffer;
UINTN DeviceHandleCount;
UINTN Index;
+ VOID *ComponentName;
+ VOID *ComponentName2;
Status = gBS->LocateHandleBuffer (
AllHandles,
@@ -148,18 +150,75 @@ Returns: &DeviceHandleCount,
&DeviceHandleBuffer
);
- if (!EFI_ERROR (Status)) {
- for (Index = 0; Index < DeviceHandleCount; Index++) {
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ for (Index = 0; Index < DeviceHandleCount; Index++) {
+ Status = EfiTestManagedDevice (DeviceHandleBuffer[Index], ImageHandle, &gEfiDiskIoProtocolGuid);
+ if (!EFI_ERROR (Status)) {
Status = gBS->DisconnectController (
DeviceHandleBuffer[Index],
ImageHandle,
NULL
);
+ if (EFI_ERROR (Status)) {
+ break;
+ }
+ }
+ }
+
+ if (Index == DeviceHandleCount) {
+ //
+ // Driver is stopped successfully.
+ //
+ Status = gBS->HandleProtocol (ImageHandle, &gEfiComponentNameProtocolGuid, &ComponentName);
+ if (EFI_ERROR (Status)) {
+ ComponentName = NULL;
}
- if (DeviceHandleBuffer != NULL) {
- FreePool (DeviceHandleBuffer);
+ Status = gBS->HandleProtocol (ImageHandle, &gEfiComponentName2ProtocolGuid, &ComponentName2);
+ if (EFI_ERROR (Status)) {
+ ComponentName2 = NULL;
}
+
+ if (ComponentName == NULL) {
+ if (ComponentName2 == NULL) {
+ Status = gBS->UninstallMultipleProtocolInterfaces (
+ ImageHandle,
+ &gEfiDriverBindingProtocolGuid, &gFatDriverBinding,
+ NULL
+ );
+ } else {
+ Status = gBS->UninstallMultipleProtocolInterfaces (
+ ImageHandle,
+ &gEfiDriverBindingProtocolGuid, &gFatDriverBinding,
+ &gEfiComponentName2ProtocolGuid, ComponentName2,
+ NULL
+ );
+ }
+ } else {
+ if (ComponentName2 == NULL) {
+ Status = gBS->UninstallMultipleProtocolInterfaces (
+ ImageHandle,
+ &gEfiDriverBindingProtocolGuid, &gFatDriverBinding,
+ &gEfiComponentNameProtocolGuid, ComponentName,
+ NULL
+ );
+ } else {
+ Status = gBS->UninstallMultipleProtocolInterfaces (
+ ImageHandle,
+ &gEfiDriverBindingProtocolGuid, &gFatDriverBinding,
+ &gEfiComponentNameProtocolGuid, ComponentName,
+ &gEfiComponentName2ProtocolGuid, ComponentName2,
+ NULL
+ );
+ }
+ }
+ }
+
+ if (DeviceHandleBuffer != NULL) {
+ FreePool (DeviceHandleBuffer);
}
return Status;
|