From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 5BCB021A02F37 for ; Thu, 15 Jun 2017 10:16:37 -0700 (PDT) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 Jun 2017 10:17:53 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.39,343,1493708400"; d="scan'208";a="99928324" Received: from orsmsx106.amr.corp.intel.com ([10.22.225.133]) by orsmga002.jf.intel.com with ESMTP; 15 Jun 2017 10:17:53 -0700 Received: from orsmsx156.amr.corp.intel.com (10.22.240.22) by ORSMSX106.amr.corp.intel.com (10.22.225.133) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 15 Jun 2017 10:17:53 -0700 Received: from orsmsx113.amr.corp.intel.com ([169.254.9.128]) by ORSMSX156.amr.corp.intel.com ([169.254.8.247]) with mapi id 14.03.0319.002; Thu, 15 Jun 2017 10:17:53 -0700 From: "Kinney, Michael D" To: Amit Kumar , "edk2-devel@lists.01.org" , "Kinney, Michael D" CC: "akamit9@hotmail.com" , "Tian, Feng" Thread-Topic: [edk2] [PATCH V2] MdeModulePkg/DxeCore: Fixed Interface returned by CoreOpenProtocol Thread-Index: AQHS5cOyidgeyDW8w0SxzC2VIREwQqImKRiA Date: Thu, 15 Jun 2017 17:17:51 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ctpclassification: CTP_IC x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiZDMzNjgzYTQtZWU4NC00ZmI3LWIwZTEtMmNkNWQ1MWY2YTI0IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjkuNi42IiwiVHJ1c3RlZExhYmVsSGFzaCI6Ik5HNjlONFJjUWpEbm9CNGt6T3F5S2JWYUh0am9wZ3ZKdHZQUlwvRUgxdUFFPSJ9 dlp-product: dlpe-windows dlp-version: 10.0.102.7 dlp-reaction: no-action x-originating-ip: [10.22.254.139] MIME-Version: 1.0 Subject: Re: [PATCH V2] MdeModulePkg/DxeCore: Fixed Interface returned by CoreOpenProtocol X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 15 Jun 2017 17:16:37 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi Kumar, One other minor comment. + // + // This is the protocol interface entry for this protocol. + // In case of any Error, Interface should not be updated as per spec. + // + if ((Attributes !=3D EFI_OPEN_PROTOCOL_TEST_PROTOCOL) + && (Status =3D=3D EFI_SUCCESS)) { + *Interface =3D Prot->Interface; + } I think it is better to use the EFI_ERROR() macro here instead of=20 direct compare against a specific status code value. // // This is the protocol interface entry for this protocol. // Only update *Interface if the protocol was found and the request // is not the test to see if the protocol is present. // if (!EFI_ERROR (Status) && Attributes !=3D EFI_OPEN_PROTOCOL_TEST_PROTOCOL)= { *Interface =3D Prot->Interface; } Mike -----Original Message----- From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Amit= Kumar Sent: Thursday, June 15, 2017 3:40 AM To: edk2-devel@lists.01.org Cc: akamit9@hotmail.com; Tian, Feng Subject: [edk2] [PATCH V2] MdeModulePkg/DxeCore: Fixed Interface returned b= y CoreOpenProtocol 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 --- MdeModulePkg/Core/Dxe/Hand/Handle.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/MdeModulePkg/Core/Dxe/Hand/Handle.c b/MdeModulePkg/Core/Dxe/Ha= nd/Handle.c index 1c25521..db23170 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 !=3D EFI_OPEN_PROTOCOL_TEST_PROTOCOL) { - if (Interface =3D=3D NULL) { - return EFI_INVALID_PARAMETER; - } else { - *Interface =3D NULL; - } + if ((Attributes !=3D EFI_OPEN_PROTOCOL_TEST_PROTOCOL) && (Interface =3D= =3D NULL)) { + return EFI_INVALID_PARAMETER; } =20 // @@ -1073,15 +1069,11 @@ CoreOpenProtocol ( Prot =3D CoreGetProtocolInterface (UserHandle, Protocol); if (Prot =3D=3D NULL) { Status =3D EFI_UNSUPPORTED; + // Return NULL Interface if Unsupported Protocol + *Interface =3D NULL; goto Done; } =20 - // - // This is the protocol interface entry for this protocol - // - if (Attributes !=3D EFI_OPEN_PROTOCOL_TEST_PROTOCOL) { - *Interface =3D Prot->Interface; - } Status =3D EFI_SUCCESS; =20 ByDriver =3D FALSE; @@ -1175,6 +1167,15 @@ CoreOpenProtocol ( } =20 Done: + + // + // This is the protocol interface entry for this protocol. + // In case of any Error, Interface should not be updated as per spec. + // + if ((Attributes !=3D EFI_OPEN_PROTOCOL_TEST_PROTOCOL) + && (Status =3D=3D EFI_SUCCESS)) { + *Interface =3D Prot->Interface; + } // // Done. Release the database lock are return // --=20 1.9.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel