From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (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 9065521AE2639 for ; Tue, 20 Jun 2017 02:56:47 -0700 (PDT) Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga105.jf.intel.com with ESMTP; 20 Jun 2017 02:58:09 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.39,364,1493708400"; d="scan'208";a="116541310" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by fmsmga005.fm.intel.com with ESMTP; 20 Jun 2017 02:58:09 -0700 Received: from fmsmsx118.amr.corp.intel.com (10.18.116.18) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 20 Jun 2017 02:58:09 -0700 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by fmsmsx118.amr.corp.intel.com (10.18.116.18) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 20 Jun 2017 02:58:08 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.146]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.56]) with mapi id 14.03.0319.002; Tue, 20 Jun 2017 17:58:05 +0800 From: "Zeng, Star" To: Amit Kumar , "edk2-devel@lists.01.org" CC: "Gao, Liming" , "Zeng, Star" Thread-Topic: [edk2] [PATCH V3] MdeModulePkg/DxeCore: Fixed Interface returned by CoreOpenProtocol Thread-Index: AQHS6PbWz0whFdszkk6K/kyrKC4wcKIthOlw Date: Tue, 20 Jun 2017 09:58:04 +0000 Message-ID: <0C09AFA07DD0434D9E2A0C6AEB0483103B8EA8C0@shsmsx102.ccr.corp.intel.com> References: <7741fb0a1a1c12f94eb6756745bc39a9bcc58135.1497874973.git.amit.ak@samsung.com> In-Reply-To: <7741fb0a1a1c12f94eb6756745bc39a9bcc58135.1497874973.git.amit.ak@samsung.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH V3] 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: Tue, 20 Jun 2017 09:56:47 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Should the code + // Return NULL Interface if Unsupported Protocol + *Interface =3D NULL; be + if (Attributes !=3D EFI_OPEN_PROTOCOL_TEST_PROTOCOL) { + // Return NULL Interface if Unsupported Protocol + *Interface =3D NULL; + } to cover the case Attributes =3D EFI_OPEN_PROTOCOL_TEST_PROTOCOL and Interf= ace =3D NULL? Thanks, Star -----Original Message----- From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Amit= Kumar Sent: Monday, June 19, 2017 8:24 PM To: edk2-devel@lists.01.org Cc: Tian, Feng Subject: [edk2] [PATCH V3] MdeModulePkg/DxeCore: Fixed Interface returned b= y 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 --- 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/Ha= nd/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 !=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,14 @@ 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 (!EFI_ERROR (Status) && Attributes !=3D EFI_OPEN_PROTOCOL_TEST_PROTOC= OL) { + *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