revert wrong commit f6334a5. EDK2 mislead

Signed-off-by: SergeySlice <sergey.slice@gmail.com>
This commit is contained in:
SergeySlice 2022-01-03 19:33:40 +03:00
parent fded3932f0
commit c493261b9c
8 changed files with 47 additions and 121 deletions

View File

@ -74,9 +74,7 @@ CoreConnectController (
//
// Make sure ControllerHandle is valid
//
CoreAcquireProtocolLock ();
Status = CoreValidateHandle (ControllerHandle);
CoreReleaseProtocolLock ();
if (EFI_ERROR(Status)) {
return Status;
}
@ -161,9 +159,7 @@ CoreConnectController (
//
// Make sure the DriverBindingHandle is valid
//
CoreAcquireProtocolLock ();
Status = CoreValidateHandle (ControllerHandle);
CoreReleaseProtocolLock ();
if (EFI_ERROR(Status)) {
//
// Release the protocol lock on the handle database
@ -277,9 +273,7 @@ AddSortedDriverBindingProtocol (
//
// Make sure the DriverBindingHandle is valid
//
CoreAcquireProtocolLock ();
Status = CoreValidateHandle (DriverBindingHandle);
CoreReleaseProtocolLock ();
if (EFI_ERROR(Status)) {
return;
}
@ -788,10 +782,8 @@ CoreDisconnectController (
//
// Make sure ControllerHandle is valid
//
CoreAcquireProtocolLock ();
Status = CoreValidateHandle (ControllerHandle);
if (EFI_ERROR(Status)) {
CoreReleaseProtocolLock ();
return Status;
}
@ -801,12 +793,10 @@ CoreDisconnectController (
if (ChildHandle != NULL) {
Status = CoreValidateHandle (ChildHandle);
if (EFI_ERROR(Status)) {
CoreReleaseProtocolLock ();
return Status;
}
}
CoreReleaseProtocolLock ();
Handle = ControllerHandle;
//

View File

@ -727,24 +727,18 @@ CoreUninstallProtocolInterface (
return EFI_INVALID_PARAMETER;
}
//
// Lock the protocol database
//
CoreAcquireProtocolLock ();
//
// Check that UserHandle is a valid handle
//
Status = CoreValidateHandle (UserHandle);
if (EFI_ERROR(Status)) {
// return Status;
goto Done;
return Status;
}
//
// Lock the protocol database
//
// CoreAcquireProtocolLock ();
CoreAcquireProtocolLock ();
//
// Check that Protocol exists on UserHandle, and Interface matches the interface in the database
@ -1019,18 +1013,12 @@ CoreOpenProtocol (
}
}
//
// Lock the protocol database
//
CoreAcquireProtocolLock ();
//
// Check for invalid UserHandle
//
Status = CoreValidateHandle (UserHandle);
if (EFI_ERROR(Status)) {
// return Status;
goto Done;
return Status;
}
//
@ -1040,26 +1028,21 @@ CoreOpenProtocol (
case EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER :
Status = CoreValidateHandle (ImageHandle);
if (EFI_ERROR(Status)) {
// return Status;
goto Done;
return Status;
}
Status = CoreValidateHandle (ControllerHandle);
if (EFI_ERROR(Status)) {
// return Status;
goto Done;
return Status;
}
if (UserHandle == ControllerHandle) {
// return EFI_INVALID_PARAMETER;
Status = EFI_INVALID_PARAMETER;
goto Done;
return EFI_INVALID_PARAMETER;
}
break;
case EFI_OPEN_PROTOCOL_BY_DRIVER :
case EFI_OPEN_PROTOCOL_BY_DRIVER | EFI_OPEN_PROTOCOL_EXCLUSIVE :
Status = CoreValidateHandle (ImageHandle);
if (EFI_ERROR(Status)) {
// return Status;
goto Done;
return Status;
}
Status = CoreValidateHandle (ControllerHandle);
if (EFI_ERROR(Status)) {
@ -1069,8 +1052,7 @@ CoreOpenProtocol (
case EFI_OPEN_PROTOCOL_EXCLUSIVE :
Status = CoreValidateHandle (ImageHandle);
if (EFI_ERROR(Status)) {
// return Status;
goto Done;
return Status;
}
break;
case EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL :
@ -1078,15 +1060,13 @@ CoreOpenProtocol (
case EFI_OPEN_PROTOCOL_TEST_PROTOCOL :
break;
default:
// return EFI_INVALID_PARAMETER;
Status = EFI_INVALID_PARAMETER;
goto Done;
return EFI_INVALID_PARAMETER;
}
//
// Lock the protocol database
//
//CoreAcquireProtocolLock ();
CoreAcquireProtocolLock ();
//
// Look at each protocol interface for a match
@ -1244,37 +1224,31 @@ CoreCloseProtocol (
LIST_ENTRY *Link;
OPEN_PROTOCOL_DATA *OpenData;
//
// Lock the protocol database
//
CoreAcquireProtocolLock ();
//
// Check for invalid parameters
//
Status = CoreValidateHandle (UserHandle);
if (EFI_ERROR(Status)) {
goto Done;
return Status;
}
Status = CoreValidateHandle (AgentHandle);
if (EFI_ERROR(Status)) {
goto Done;
return Status;
}
if (ControllerHandle != NULL) {
Status = CoreValidateHandle (ControllerHandle);
if (EFI_ERROR(Status)) {
goto Done;
return Status;
}
}
if (Protocol == NULL) {
Status = EFI_INVALID_PARAMETER;
goto Done;
return EFI_INVALID_PARAMETER;
}
//
// Lock the protocol database
//
//CoreAcquireProtocolLock ();
CoreAcquireProtocolLock ();
//
// Look at each protocol interface for a match
@ -1468,14 +1442,6 @@ CoreProtocolsPerHandle (
CoreAcquireProtocolLock ();
Status = CoreValidateHandle (UserHandle);
if (EFI_ERROR (Status)) {
goto Done;
}
Handle = (IHANDLE *)UserHandle;
for (Link = Handle->Protocols.ForwardLink; Link != &Handle->Protocols; Link = Link->ForwardLink) {
ProtocolCount++;
}

View File

@ -248,7 +248,6 @@ CoreReleaseProtocolLock (
/**
Check whether a handle is a valid EFI_HANDLE
The gProtocolDatabaseLock must be owned
@param UserHandle The handle to check

View File

@ -193,28 +193,22 @@ CoreReinstallProtocolInterface (
PROTOCOL_INTERFACE *Prot;
PROTOCOL_ENTRY *ProtEntry;
// Status = CoreValidateHandle (UserHandle);
// if (EFI_ERROR(Status)) {
// return Status;
// }
Status = CoreValidateHandle (UserHandle);
if (EFI_ERROR(Status)) {
return Status;
}
if (Protocol == NULL) {
return EFI_INVALID_PARAMETER;
}
// Handle = (IHANDLE *) UserHandle;
Handle = (IHANDLE *) UserHandle;
//
// Lock the protocol database
//
CoreAcquireProtocolLock ();
Status = CoreValidateHandle (UserHandle);
if (EFI_ERROR (Status)) {
goto Done;
}
Handle = (IHANDLE *) UserHandle;
//
// Check that Protocol exists on UserHandle, and Interface matches the interface in the database
//

View File

@ -68,9 +68,7 @@ CoreConnectController (
//
// Make sure ControllerHandle is valid
//
CoreAcquireProtocolLock ();
Status = CoreValidateHandle (ControllerHandle);
CoreReleaseProtocolLock ();
if (EFI_ERROR(Status)) {
return Status;
}
@ -270,9 +268,7 @@ AddSortedDriverBindingProtocol (
//
// Make sure the DriverBindingHandle is valid
//
CoreAcquireProtocolLock ();
Status = CoreValidateHandle (DriverBindingHandle);
CoreReleaseProtocolLock ();
if (EFI_ERROR(Status)) {
return;
}
@ -750,10 +746,8 @@ CoreDisconnectController (
//
// Make sure ControllerHandle is valid
//
CoreAcquireProtocolLock ();
Status = CoreValidateHandle (ControllerHandle);
if (EFI_ERROR(Status)) {
CoreReleaseProtocolLock ();
return Status;
}
@ -763,11 +757,10 @@ CoreDisconnectController (
if (ChildHandle != NULL) {
Status = CoreValidateHandle (ChildHandle);
if (EFI_ERROR(Status)) {
CoreReleaseProtocolLock ();
return Status;
}
}
CoreReleaseProtocolLock ();
Handle = ControllerHandle;
//

View File

@ -1002,17 +1002,12 @@ CoreOpenProtocol (
return EFI_INVALID_PARAMETER;
}
//
// Lock the protocol database
//
CoreAcquireProtocolLock ();
//
// Check for invalid UserHandle
//
Status = CoreValidateHandle (UserHandle);
if (EFI_ERROR(Status)) {
goto Done;
return Status;
}
//
@ -1022,32 +1017,31 @@ CoreOpenProtocol (
case EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER :
Status = CoreValidateHandle (ImageHandle);
if (EFI_ERROR(Status)) {
goto Done;
return Status;
}
Status = CoreValidateHandle (ControllerHandle);
if (EFI_ERROR(Status)) {
goto Done;
return Status;
}
if (UserHandle == ControllerHandle) {
Status = EFI_INVALID_PARAMETER;
goto Done;
return EFI_INVALID_PARAMETER;
}
break;
case EFI_OPEN_PROTOCOL_BY_DRIVER :
case EFI_OPEN_PROTOCOL_BY_DRIVER | EFI_OPEN_PROTOCOL_EXCLUSIVE :
Status = CoreValidateHandle (ImageHandle);
if (EFI_ERROR(Status)) {
goto Done;
return Status;
}
Status = CoreValidateHandle (ControllerHandle);
if (EFI_ERROR(Status)) {
goto Done;
return Status;
}
break;
case EFI_OPEN_PROTOCOL_EXCLUSIVE :
Status = CoreValidateHandle (ImageHandle);
if (EFI_ERROR(Status)) {
goto Done;
return Status;
}
break;
case EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL :
@ -1055,14 +1049,13 @@ CoreOpenProtocol (
case EFI_OPEN_PROTOCOL_TEST_PROTOCOL :
break;
default:
Status = EFI_INVALID_PARAMETER;
goto Done;
return EFI_INVALID_PARAMETER;
}
//
// Lock the protocol database
//
//CoreAcquireProtocolLock ();
CoreAcquireProtocolLock ();
//
// Look at each protocol interface for a match
@ -1245,37 +1238,31 @@ CoreCloseProtocol (
LIST_ENTRY *Link;
OPEN_PROTOCOL_DATA *OpenData;
//
// Lock the protocol database
//
CoreAcquireProtocolLock ();
//
// Check for invalid parameters
//
Status = CoreValidateHandle (UserHandle);
if (EFI_ERROR(Status)) {
goto Done;
return Status;
}
Status = CoreValidateHandle (AgentHandle);
if (EFI_ERROR(Status)) {
goto Done;
return Status;
}
if (ControllerHandle != NULL) {
Status = CoreValidateHandle (ControllerHandle);
if (EFI_ERROR(Status)) {
goto Done;
return Status;
}
}
if (Protocol == NULL) {
Status = EFI_INVALID_PARAMETER;
goto Done;
return EFI_INVALID_PARAMETER;
}
//
// Lock the protocol database
//
//CoreAcquireProtocolLock ();
CoreAcquireProtocolLock ();
//
// Look at each protocol interface for a match
@ -1448,6 +1435,12 @@ CoreProtocolsPerHandle (
UINTN ProtocolCount;
EFI_GUID **Buffer;
Status = CoreValidateHandle (UserHandle);
if (EFI_ERROR(Status)) {
return Status;
}
Handle = (IHANDLE *)UserHandle;
if (ProtocolBuffer == NULL) {
return EFI_INVALID_PARAMETER;
@ -1463,14 +1456,6 @@ CoreProtocolsPerHandle (
CoreAcquireProtocolLock ();
Status = CoreValidateHandle (UserHandle);
if (EFI_ERROR(Status)) {
goto Done;
}
Handle = (IHANDLE *)UserHandle;
for (Link = Handle->Protocols.ForwardLink; Link != &Handle->Protocols; Link = Link->ForwardLink) {
ProtocolCount++;
}

View File

@ -242,7 +242,6 @@ CoreReleaseProtocolLock (
/**
Check whether a handle is a valid EFI_HANDLE
The gProtocolDatabaseLock must be owned
@param UserHandle The handle to check

View File

@ -188,22 +188,22 @@ CoreReinstallProtocolInterface (
PROTOCOL_INTERFACE *Prot;
PROTOCOL_ENTRY *ProtEntry;
Status = CoreValidateHandle (UserHandle);
if (EFI_ERROR(Status)) {
return Status;
}
if (Protocol == NULL) {
return EFI_INVALID_PARAMETER;
}
Handle = (IHANDLE *) UserHandle;
//
// Lock the protocol database
//
CoreAcquireProtocolLock ();
Status = CoreValidateHandle (UserHandle);
if (EFI_ERROR (Status)) {
goto Done;
}
Handle = (IHANDLE *) UserHandle;
//
// Check that Protocol exists on UserHandle, and Interface matches the interface in the database
//