mirror of https://github.com/acidanthera/audk.git
MdeModulePkg/NvmExpressDxe: Fix a bug in NvmExpressDxe driver’s Unload() that forget to uninstall the DriverSupportedEfiVersionProtocol
Signed-off-by: Feng Tian <feng.tian@intel.com> Reviewed-by: Elvin Li <elvin.li@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15090 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
2bc3256ca6
commit
0a2326aff7
|
@ -928,97 +928,102 @@ NvmExpressUnload (
|
||||||
EFI_HANDLE *DeviceHandleBuffer;
|
EFI_HANDLE *DeviceHandleBuffer;
|
||||||
UINTN DeviceHandleCount;
|
UINTN DeviceHandleCount;
|
||||||
UINTN Index;
|
UINTN Index;
|
||||||
EFI_DRIVER_BINDING_PROTOCOL *DriverBinding;
|
|
||||||
EFI_COMPONENT_NAME_PROTOCOL *ComponentName;
|
EFI_COMPONENT_NAME_PROTOCOL *ComponentName;
|
||||||
EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2;
|
EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Get the list of all the handles in the handle database.
|
// Get the list of the device handles managed by this driver.
|
||||||
// If there is an error getting the list, then the unload
|
// If there is an error getting the list, then means the driver
|
||||||
// operation fails.
|
// doesn't manage any device. At this way, we would only close
|
||||||
|
// those protocols installed at image handle.
|
||||||
//
|
//
|
||||||
|
DeviceHandleBuffer = NULL;
|
||||||
Status = gBS->LocateHandleBuffer (
|
Status = gBS->LocateHandleBuffer (
|
||||||
AllHandles,
|
ByProtocol,
|
||||||
NULL,
|
&gEfiCallerIdGuid,
|
||||||
NULL,
|
NULL,
|
||||||
&DeviceHandleCount,
|
&DeviceHandleCount,
|
||||||
&DeviceHandleBuffer
|
&DeviceHandleBuffer
|
||||||
);
|
);
|
||||||
|
|
||||||
if (EFI_ERROR (Status)) {
|
if (!EFI_ERROR (Status)) {
|
||||||
return Status;
|
//
|
||||||
}
|
// Disconnect the driver specified by ImageHandle from all
|
||||||
|
// the devices in the handle database.
|
||||||
//
|
//
|
||||||
// Disconnect the driver specified by ImageHandle from all
|
for (Index = 0; Index < DeviceHandleCount; Index++) {
|
||||||
// the devices in the handle database.
|
Status = gBS->DisconnectController (
|
||||||
//
|
DeviceHandleBuffer[Index],
|
||||||
for (Index = 0; Index < DeviceHandleCount; Index++) {
|
ImageHandle,
|
||||||
Status = gBS->DisconnectController (
|
NULL
|
||||||
DeviceHandleBuffer[Index],
|
);
|
||||||
ImageHandle,
|
if (EFI_ERROR (Status)) {
|
||||||
NULL
|
goto EXIT;
|
||||||
);
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Uninstall all the protocols installed in the driver entry point
|
// Uninstall all the protocols installed in the driver entry point
|
||||||
//
|
//
|
||||||
for (Index = 0; Index < DeviceHandleCount; Index++) {
|
Status = gBS->UninstallMultipleProtocolInterfaces (
|
||||||
Status = gBS->HandleProtocol (
|
ImageHandle,
|
||||||
DeviceHandleBuffer[Index],
|
&gEfiDriverBindingProtocolGuid,
|
||||||
&gEfiDriverBindingProtocolGuid,
|
&gNvmExpressDriverBinding,
|
||||||
(VOID **) &DriverBinding
|
&gEfiDriverSupportedEfiVersionProtocolGuid,
|
||||||
);
|
&gNvmExpressDriverSupportedEfiVersion,
|
||||||
|
NULL
|
||||||
|
);
|
||||||
|
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
continue;
|
goto EXIT;
|
||||||
}
|
|
||||||
|
|
||||||
if (DriverBinding->ImageHandle != ImageHandle) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
gBS->UninstallProtocolInterface (
|
|
||||||
ImageHandle,
|
|
||||||
&gEfiDriverBindingProtocolGuid,
|
|
||||||
DriverBinding
|
|
||||||
);
|
|
||||||
|
|
||||||
Status = gBS->HandleProtocol (
|
|
||||||
DeviceHandleBuffer[Index],
|
|
||||||
&gEfiComponentNameProtocolGuid,
|
|
||||||
(VOID **) &ComponentName
|
|
||||||
);
|
|
||||||
if (!EFI_ERROR (Status)) {
|
|
||||||
gBS->UninstallProtocolInterface (
|
|
||||||
ImageHandle,
|
|
||||||
&gEfiComponentNameProtocolGuid,
|
|
||||||
ComponentName
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Status = gBS->HandleProtocol (
|
|
||||||
DeviceHandleBuffer[Index],
|
|
||||||
&gEfiComponentName2ProtocolGuid,
|
|
||||||
(VOID **) &ComponentName2
|
|
||||||
);
|
|
||||||
if (!EFI_ERROR (Status)) {
|
|
||||||
gBS->UninstallProtocolInterface (
|
|
||||||
ImageHandle,
|
|
||||||
&gEfiComponentName2ProtocolGuid,
|
|
||||||
ComponentName2
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Note we have to one by one uninstall the following protocols.
|
||||||
|
// It's because some of them are optionally installed based on
|
||||||
|
// the following PCD settings.
|
||||||
|
// gEfiMdePkgTokenSpaceGuid.PcdDriverDiagnosticsDisable
|
||||||
|
// gEfiMdePkgTokenSpaceGuid.PcdComponentNameDisable
|
||||||
|
// gEfiMdePkgTokenSpaceGuid.PcdDriverDiagnostics2Disable
|
||||||
|
// gEfiMdePkgTokenSpaceGuid.PcdComponentName2Disable
|
||||||
|
//
|
||||||
|
Status = gBS->HandleProtocol (
|
||||||
|
ImageHandle,
|
||||||
|
&gEfiComponentNameProtocolGuid,
|
||||||
|
(VOID **) &ComponentName
|
||||||
|
);
|
||||||
|
if (!EFI_ERROR (Status)) {
|
||||||
|
gBS->UninstallProtocolInterface (
|
||||||
|
ImageHandle,
|
||||||
|
&gEfiComponentNameProtocolGuid,
|
||||||
|
ComponentName
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Status = gBS->HandleProtocol (
|
||||||
|
ImageHandle,
|
||||||
|
&gEfiComponentName2ProtocolGuid,
|
||||||
|
(VOID **) &ComponentName2
|
||||||
|
);
|
||||||
|
if (!EFI_ERROR (Status)) {
|
||||||
|
gBS->UninstallProtocolInterface (
|
||||||
|
ImageHandle,
|
||||||
|
&gEfiComponentName2ProtocolGuid,
|
||||||
|
ComponentName2
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Status = EFI_SUCCESS;
|
||||||
|
|
||||||
|
EXIT:
|
||||||
//
|
//
|
||||||
// Free the buffer containing the list of handles from the handle database
|
// Free the buffer containing the list of handles from the handle database
|
||||||
//
|
//
|
||||||
if (DeviceHandleBuffer != NULL) {
|
if (DeviceHandleBuffer != NULL) {
|
||||||
gBS->FreePool (DeviceHandleBuffer);
|
gBS->FreePool (DeviceHandleBuffer);
|
||||||
}
|
}
|
||||||
return EFI_SUCCESS;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue