mirror of https://github.com/acidanthera/audk.git
MdeModulePkg/DxeCore: Fixed Interface returned by CoreOpenProtocol
Change since v4: Revise the patch based on V4 sent by Amit Kumar 1) Only return the corresponding protocol interface in *Interface if the return status is EFI_SUCCESS or EFI_ALREADY_STARTED. 2) Interface is returned unmodified for all error conditions except EFI_UNSUPPORTED and EFI_ALREADY_STARTED, NULL will be returned in *Interface when EFI_UNSUPPORTED and Attributes is not EFI_OPEN_PROTOCOL_TEST_PROTOCOL, the protocol interface will be returned in *Interface when EFI_ALREADY_STARTED. 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 Cc: Laszlo Ersek <lersek@redhat.com> Cc: Amit Kumar <amit.ak@samsung.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Cc: Liming Gao <liming.gao@intel.com> Cc: Gabriel Somlo <gsomlo@gmail.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Amit Kumar <amit.ak@samsung.com> Signed-off-by: Star Zeng <star.zeng@intel.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com> Tested-by: Laszlo Ersek <lersek@redhat.com> Tested-by: Gabriel Somlo <gsomlo@gmail.com>
This commit is contained in:
parent
560a435df0
commit
89f7f2cdf0
|
@ -1004,12 +1004,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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -1076,12 +1072,6 @@ CoreOpenProtocol (
|
||||||
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,8 +1167,28 @@ CoreOpenProtocol (
|
||||||
}
|
}
|
||||||
|
|
||||||
Done:
|
Done:
|
||||||
|
|
||||||
|
if (Attributes != EFI_OPEN_PROTOCOL_TEST_PROTOCOL) {
|
||||||
|
//
|
||||||
|
// Keep Interface unmodified in case of any Error
|
||||||
|
// except EFI_ALREADY_STARTED and EFI_UNSUPPORTED.
|
||||||
|
//
|
||||||
|
if (!EFI_ERROR (Status) || Status == EFI_ALREADY_STARTED) {
|
||||||
|
//
|
||||||
|
// EFI_ALREADY_STARTED is not an error for bus driver.
|
||||||
|
// Return the corresponding protocol interface.
|
||||||
|
//
|
||||||
|
*Interface = Prot->Interface;
|
||||||
|
} else if (Status == EFI_UNSUPPORTED) {
|
||||||
|
//
|
||||||
|
// Return NULL Interface if Unsupported Protocol.
|
||||||
|
//
|
||||||
|
*Interface = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Done. Release the database lock are return
|
// Done. Release the database lock and return
|
||||||
//
|
//
|
||||||
CoreReleaseProtocolLock ();
|
CoreReleaseProtocolLock ();
|
||||||
return Status;
|
return Status;
|
||||||
|
|
Loading…
Reference in New Issue