From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) (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 3BB5A21A08D63 for ; Tue, 13 Jun 2017 05:42:22 -0700 (PDT) Received: from epcas1p3.samsung.com (unknown [182.195.41.47]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20170613124334epoutp04206dd31dbb8ffc431c334129db0fbb4f~Hrv-Q2R3t2354923549epoutp04z; Tue, 13 Jun 2017 12:43:34 +0000 (GMT) Received: from epsmges1p5.samsung.com (unknown [182.195.42.57]) by epcas1p3.samsung.com (KnoxPortal) with ESMTP id 20170613124333epcas1p370bb9cce79e2d283d9bdaed9fe66e954~Hrv_Moau80248702487epcas1p3m; Tue, 13 Jun 2017 12:43:33 +0000 (GMT) Received: from epcas1p4.samsung.com ( [182.195.41.48]) by epsmges1p5.samsung.com (Symantec Messaging Gateway) with SMTP id 08.2D.03717.5FDDF395; Tue, 13 Jun 2017 21:43:33 +0900 (KST) Received: from epsmgms2p1.samsung.com (unknown [182.195.42.79]) by epcas1p2.samsung.com (KnoxPortal) with ESMTP id 20170613124333epcas1p2d82549b72e339e5d553b7e4ee09bfe3a~Hrv9jmxY60078200782epcas1p2_; Tue, 13 Jun 2017 12:43:33 +0000 (GMT) X-AuditID: b6c32a39-f790c6d000000e85-92-593fddf52997 Received: from epmmp2 ( [203.254.227.17]) by epsmgms2p1.samsung.com (Symantec Messaging Gateway) with SMTP id 68.7D.02179.4FDDF395; Tue, 13 Jun 2017 21:43:33 +0900 (KST) Received: from amit.kp-ubuntu.sisodomain.com ([107.108.221.253]) by mmp2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0ORH003SSKOESMA0@mmp2.samsung.com>; Tue, 13 Jun 2017 21:43:32 +0900 (KST) From: Amit Kumar To: edk2-devel@lists.01.org Cc: feng.tian@intel.com, Amit Kumar Date: Tue, 13 Jun 2017 18:14:34 +0530 Message-id: X-Mailer: git-send-email 1.9.1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprPIsWRmVeSWpSXmKPExsWy7bCmge7Xu/aRBttuallsObCJ1WLPoaPM FpN2szsweyze85LJo3v2PxaPvi2rGAOYo7hsUlJzMstSi/TtErgybp2/w1bQKFAxfddl1gbG LTxdjJwcEgImEvsbN7NA2GISF+6tZ+ti5OIQEtjBKLHyXBs7hPOZUWLZ9cnMMB0rz66ESqxl lJj19CCU08Qkcf/CbLAqNgE1iakti1hBbBEBaYkNV9cDFXFwMAtYSqyeXwcSFhYIlfg8rQWs nEVAVWJm80EmEJtXIFri1vFOqGVyEiePTWYFmS8hsIBNYtGa/8wgcyQEZCU2HYCqcZFYd38H lC0s8er4FnYIW0qi8eVDJgi7WmLpl/mMEHNaGCXmfbwG1WAvcXHPX7AiZgE+iXdfe1gh5vNK dLQJQZgeEq034iCqHSWaVi4AGy8kECuxbNVWtgmM0gsYGVYxiqUWFOempxYbFpjqFSfmFpfm pesl5+duYgRHm5blDsZj53wOMQpwMCrx8K6YZBcpxJpYVlyZe4hRgoNZSYRX4LZ9pBBvSmJl VWpRfnxRaU5q8SFGaQ4WJXFe0fXXIoQE0hNLUrNTUwtSi2CyTBycUg2MJ/7tzrsa6vCQ5czR 3HvZEh4bPbotORZIh771LJVfwTS3n2FZ8TLtxVnWEVvLP3vd5jvPs2it1tOUvwt1y947nd0r kiM8dcds86mT9t3b3KHT5ehgy8C4bbWSxq9Zf4yuModlRBXdTqtsKLWLFq7WzEr3+ZZ34Y94 a1/sRd8P8Q+zk6TsXtsosRRnJBpqMRcVJwIAy4PByrICAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrOLMWRmVeSWpSXmKPExsVy+t9jQd2vd+0jDb65WWw5sInVYs+ho8wW k3azOzB7LN7zksmje/Y/Fo++LasYA5ij3GwyUhNTUosUUvOS81My89JtlUJD3HQtlBTyEnNT bZUidH1DgpQUyhJzSoE8IwM04OAc4B6spG+X4JZx6/wdtoJGgYrpuy6zNjBu4eli5OSQEDCR WHl2JTuELSZx4d56ti5GLg4hgdWMEl8PL2SEcFqYJJqnH2YEqWITUJOY2rKIFcQWEZCW2HB1 PVA3BwezgKXE6vl1IGFhgVCJz9NamEFsFgFViZnNB5lAbF6BaImfU3tYIZbJSZw8Npl1AiP3 AkaGVYxcqQXFuem5xUYFhpsYgYG07bCW/w7GH2ejDzEKcDAq8fCumGQXKcSaWFZcmXuIUYKD WUmEV+C2faQQb0piZVVqUX58UWlOavEhRlOglROZpUST84FBnlcSb2hiaWRiYGZmaGRgbKYk zjsh8EuEkEB6YklqdmpqQWoRTB8TB6dUAyNz+j7TBbGLzyoELNksMn2GeONzA//J2ptj/91V v/I5oEu9WEn8fph4XE7/tJ3zt76SiMo7fGoHq0fj16AzP35umOMaPdOr5aeKRuh059jLbzwk 7Hkuaxn3GPO/3sCxdPGUpy8F787KUJ79/YppLdd3NslNmc+PmWxaZpi32sApTUHwIM813WIl luKMREMt5qLiRAA3ihtnOgIAAA== X-MTR: 20000000000000000@CPGS X-CMS-MailID: 20170613124333epcas1p2d82549b72e339e5d553b7e4ee09bfe3a X-Msg-Generator: CA X-Sender-IP: 182.195.42.79 X-Local-Sender: =?UTF-8?B?QW1pdCBLdW1hchtTU0lSLUhvc3QgU29sdXRpb25zG+yCvA==?= =?UTF-8?B?7ISx7KCE7J6QG0xlYWQgRW5naW5lZXI=?= X-Global-Sender: =?UTF-8?B?QW1pdCBLdW1hchtTU0lSLUhvc3QgU29sdXRpb25zG1NhbXN1?= =?UTF-8?B?bmcgRWxlY3Ryb25pY3MbTGVhZCBFbmdpbmVlcg==?= X-Sender-Code: =?UTF-8?B?QzEwG1NXQUhRG0MxMElEMDdJRDAxMTAxMw==?= CMS-TYPE: 101P X-CMS-RootMailID: 20170613124333epcas1p2d82549b72e339e5d553b7e4ee09bfe3a X-RootMTR: 20170613124333epcas1p2d82549b72e339e5d553b7e4ee09bfe3a References: Subject: [PATCH] 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, 13 Jun 2017 12:42:22 -0000 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 | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/MdeModulePkg/Core/Dxe/Hand/Handle.c b/MdeModulePkg/Core/Dxe/Hand/Handle.c index 1c25521..0afa86b 100644 --- a/MdeModulePkg/Core/Dxe/Hand/Handle.c +++ b/MdeModulePkg/Core/Dxe/Hand/Handle.c @@ -1004,13 +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; // // Check for invalid UserHandle @@ -1073,15 +1068,11 @@ CoreOpenProtocol ( Prot = CoreGetProtocolInterface (UserHandle, Protocol); if (Prot == NULL) { Status = EFI_UNSUPPORTED; + // Return NULL Interface if Unsupported Protocal + *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 +1166,15 @@ 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 ((Attributes != EFI_OPEN_PROTOCOL_TEST_PROTOCOL) + && (Status == EFI_SUCCESS)) { + *Interface = Prot->Interface; + } // // Done. Release the database lock are return // -- 1.9.1