MdeModulePkg/DxeCore: Fixed Interface returned by CoreOpenProtocol
Change since v3: 1) Fixed issue when Attributes = EFI_OPEN_PROTOCOL_TEST_PROTOCOL and Inteface = NULL case. [Reported by:star.zeng at intel.com] Change Since v2: 1) Modified to use EFI_ERROR to get status code Change since v1: 1) Fixed typo protocal to protocol 2) Fixed coding style Modified source code to update Interface as per spec. 1) In case of Protocol is un-supported, interface should be returned NULL. 2) In case of any error, interface should not be modified. 3) In case of Test Protocol, interface is optional. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Amit Kumar <amit.ak@samsung.com> Reviewed-by: Liming Gao <liming.gao@intel.com> Reviewed-by: Star Zeng <star.zeng@intel.com>
This commit is contained in:
@ -1006,12 +1006,8 @@ CoreOpenProtocol (
|
|||||||
//
|
//
|
||||||
// Check for invalid Interface
|
// Check for invalid Interface
|
||||||
//
|
//
|
||||||
if (Attributes != EFI_OPEN_PROTOCOL_TEST_PROTOCOL) {
|
if ((Attributes != EFI_OPEN_PROTOCOL_TEST_PROTOCOL) && (Interface == NULL)) {
|
||||||
if (Interface == NULL) {
|
return EFI_INVALID_PARAMETER;
|
||||||
return EFI_INVALID_PARAMETER;
|
|
||||||
} else {
|
|
||||||
*Interface = NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -1075,15 +1071,13 @@ CoreOpenProtocol (
|
|||||||
Prot = CoreGetProtocolInterface (UserHandle, Protocol);
|
Prot = CoreGetProtocolInterface (UserHandle, Protocol);
|
||||||
if (Prot == NULL) {
|
if (Prot == NULL) {
|
||||||
Status = EFI_UNSUPPORTED;
|
Status = EFI_UNSUPPORTED;
|
||||||
|
if (Attributes != EFI_OPEN_PROTOCOL_TEST_PROTOCOL){
|
||||||
|
//Return NULL Interface if Unsupported Protocol
|
||||||
|
*Interface = NULL;
|
||||||
|
}
|
||||||
goto Done;
|
goto Done;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// This is the protocol interface entry for this protocol
|
|
||||||
//
|
|
||||||
if (Attributes != EFI_OPEN_PROTOCOL_TEST_PROTOCOL) {
|
|
||||||
*Interface = Prot->Interface;
|
|
||||||
}
|
|
||||||
Status = EFI_SUCCESS;
|
Status = EFI_SUCCESS;
|
||||||
|
|
||||||
ByDriver = FALSE;
|
ByDriver = FALSE;
|
||||||
@ -1177,6 +1171,14 @@ CoreOpenProtocol (
|
|||||||
}
|
}
|
||||||
|
|
||||||
Done:
|
Done:
|
||||||
|
|
||||||
|
//
|
||||||
|
// This is the protocol interface entry for this protocol.
|
||||||
|
// In case of any Error, Interface should not be updated as per spec.
|
||||||
|
//
|
||||||
|
if (!EFI_ERROR (Status) && (Attributes != EFI_OPEN_PROTOCOL_TEST_PROTOCOL)) {
|
||||||
|
*Interface = Prot->Interface;
|
||||||
|
}
|
||||||
//
|
//
|
||||||
// Done. Release the database lock are return
|
// Done. Release the database lock are return
|
||||||
//
|
//
|
||||||
|
Reference in New Issue
Block a user