Reviewed-by: Liming Gao <[email protected]>
> -----Original Message----- > From: edk2-devel [mailto:[email protected]] On Behalf Of Amit > Kumar > Sent: Monday, June 19, 2017 8:24 PM > To: [email protected] > Cc: Tian, Feng <[email protected]> > Subject: [edk2] [PATCH V3] MdeModulePkg/DxeCore: Fixed Interface returned by > CoreOpenProtocol > > 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 <[email protected]> > --- > MdeModulePkg/Core/Dxe/Hand/Handle.c | 24 ++++++++++++------------ > 1 file changed, 12 insertions(+), 12 deletions(-) > > diff --git a/MdeModulePkg/Core/Dxe/Hand/Handle.c > b/MdeModulePkg/Core/Dxe/Hand/Handle.c > index 1c25521..6de300f 100644 > --- a/MdeModulePkg/Core/Dxe/Hand/Handle.c > +++ b/MdeModulePkg/Core/Dxe/Hand/Handle.c > @@ -1004,12 +1004,8 @@ CoreOpenProtocol ( > // > // Check for invalid Interface > // > - if (Attributes != EFI_OPEN_PROTOCOL_TEST_PROTOCOL) { > - if (Interface == NULL) { > - return EFI_INVALID_PARAMETER; > - } else { > - *Interface = NULL; > - } > + if ((Attributes != EFI_OPEN_PROTOCOL_TEST_PROTOCOL) && (Interface == > NULL)) { > + return EFI_INVALID_PARAMETER; > } > > // > @@ -1073,15 +1069,11 @@ CoreOpenProtocol ( > Prot = CoreGetProtocolInterface (UserHandle, Protocol); > if (Prot == NULL) { > Status = EFI_UNSUPPORTED; > + // Return NULL Interface if Unsupported Protocol > + *Interface = NULL; > goto Done; > } > > - // > - // This is the protocol interface entry for this protocol > - // > - if (Attributes != EFI_OPEN_PROTOCOL_TEST_PROTOCOL) { > - *Interface = Prot->Interface; > - } > Status = EFI_SUCCESS; > > ByDriver = FALSE; > @@ -1175,6 +1167,14 @@ CoreOpenProtocol ( > } > > 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 > // > -- > 1.9.1 > > _______________________________________________ > edk2-devel mailing list > [email protected] > https://lists.01.org/mailman/listinfo/edk2-devel _______________________________________________ edk2-devel mailing list [email protected] https://lists.01.org/mailman/listinfo/edk2-devel

