From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mailout1.samsung.com (mailout1.samsung.com [203.254.224.24]) (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 B20DF21962334 for ; Mon, 19 Jun 2017 05:21:37 -0700 (PDT) Received: from epcas5p4.samsung.com (unknown [182.195.41.42]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20170619122256epoutp014831d58a979f5c8dcb3c80ec8b7e7ea0~JhVrSLeVs2606226062epoutp01I; Mon, 19 Jun 2017 12:22:56 +0000 (GMT) Received: from epsmges5p1.samsung.com (unknown [182.195.42.44]) by epcas5p3.samsung.com (KnoxPortal) with ESMTP id 20170619122255epcas5p3a83b6936cfe0b7e3b637299b4f7c78e7~JhVqpvVJZ1321413214epcas5p37; Mon, 19 Jun 2017 12:22:55 +0000 (GMT) Received: from epcas5p4.samsung.com ( [182.195.41.42]) by epsmges5p1.samsung.com (EPCPMTA) with SMTP id 7B.27.04764.F12C7495; Mon, 19 Jun 2017 21:22:55 +0900 (KST) Received: from epsmgms2p2.samsung.com (unknown [182.195.42.80]) by epcas5p4.samsung.com (KnoxPortal) with ESMTP id 20170619122254epcas5p49c12385e361c09d50eb4d0dfea71f41a~JhVpzXrQv1520215202epcas5p4Y; Mon, 19 Jun 2017 12:22:54 +0000 (GMT) X-AuditID: b6c32a2c-f79e76d00000129c-56-5947c21f25bd Received: from epmmp2 ( [203.254.227.17]) by epsmgms2p2.samsung.com (Symantec Messaging Gateway) with SMTP id 3E.95.05071.E12C7495; Mon, 19 Jun 2017 21:22:54 +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 <0ORS00ISHNPZSW40@mmp2.samsung.com>; Mon, 19 Jun 2017 21:22:54 +0900 (KST) From: Amit Kumar To: edk2-devel@lists.01.org Cc: feng.tian@intel.com, akamit91@hotmail.com, Amit Kumar Date: Mon, 19 Jun 2017 17:53:51 +0530 Message-id: <7741fb0a1a1c12f94eb6756745bc39a9bcc58135.1497874973.git.amit.ak@samsung.com> X-Mailer: git-send-email 1.9.1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrFIsWRmVeSWpSXmKPExsWy7bCmlq78IfdIg6brshb7Xu9ksthyYBOr xZ5DR5ktJu1md2DxeNxzhs1j8Z6XTB7ds/+xePRtWcUYwBLFZZOSmpNZllqkb5fAlbH1xg+m gscCFWsnvWdpYGzm7WLk5JAQMJE482cnI4QtJnHh3nq2LkYuDiGBpYwS2w4dZYdwPjNK9H3p ZIbp6L93D6pqLaPEqZ+NrBBOE5PE/Y6LYLPYBNQkprYsYgWxRQSkJTZcXc8OYjMLBEo09F9h AbGFBSIk1m6+BVbPIqAqcb/zLFCcg4NXIFpiwYZiiGVyEiePTQabLyGwgk3iz7YbzCA1EgKy EpsOQB3kItGzdw0bhC0s8er4FnYIW0qiu2MWlF0tsfTLfEaIOS2MEvM+XoNqtpe4uOcvE8Rt fBK9v58wQcznlehoE4Io8QAGy0omCNtRYvLprWDnCwnESrw9Mo95AqP0AkaGVYxiqQXFuemp xaYFhnrFibnFpXnpesn5uZsYwTGopbOD8d4C70OMAhyMSjy8F166RQqxJpYVV+YeYpTgYFYS 4b24zj1SiDclsbIqtSg/vqg0J7X4EKM0B4uSOK/GymsRQgLpiSWp2ampBalFMFkmDk6pBsb4 EyExgtxTMmtt397mi/SZmn76iWD8sefN5Yp6So+srhcd3Dj/sbvBCVb7A2u6jut05nB7pIix mr16avAr++LbSYUv7Sw2V97Tjn6/9/F8/vtHZhSlTmKa2rJFRVPvLzuj0YnkFacNbpVsmCIS t1zvQFSUdvkD+c2ue99tNTq0iuvxl1CuHdVKLMUZiYZazEXFiQCFkXv+vQIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrMLMWRmVeSWpSXmKPExsVy+t9jQV25Q+6RBs/OK1vse72TyWLLgU2s FnsOHWW2mLSb3YHF43HPGTaPxXteMnl0z/7H4tG3ZRVjAEuUm01GamJKapFCal5yfkpmXrqt UmiIm66FkkJeYm6qrVKErm9IkJJCWWJOKZBnZIAGHJwD3IOV9O0S3DK23vjBVPBYoGLtpPcs DYzNvF2MnBwSAiYS/ffusUHYYhIX7q0Hsrk4hARWM0rMO/ebBcJpYZJ41zmbGaSKTUBNYmrL IlYQW0RAWmLD1fXsIDazgL/Ej3O7WUBsYYEIibWbbzGC2CwCqhL3O8+CxXkFoiX2dbxkhdgm J3Hy2GTWCYzcCxgZVjFypRYU56bnFhsVGG1iBAbYtsNaATsYm85FH2IU4GBU4uG98NItUog1 say4MvcQowQHs5II78V17pFCvCmJlVWpRfnxRaU5qcWHGE2BVk5klhJNzgcGf15JvKGJpZGJ gZmZoZGBsZmSOO+EwC8RQgLpiSWp2ampBalFMH1MHJxSDYzqx3/+ZXjEU51uIdNylS/sUmPm fOeVbnWaTu83398gXOIjK2VX+r5M5kQcT9C2uRG7dCa127p2sxt3+YtMOb3AVaS0N4ytMM3u BpNcwb6iBzv4d7Mbzo5Qn18ftn3Stj9HjqueVJEJ/1ywr3ThzjtXfWYl8z87vSX8YGHU9gyL u2UMGi2nHZRYijMSDbWYi4oTASnwXj5GAgAA X-MTR: 20000000000000000@CPGS X-CMS-MailID: 20170619122254epcas5p49c12385e361c09d50eb4d0dfea71f41a X-Msg-Generator: CA X-Sender-IP: 182.195.42.80 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: 105P X-CMS-RootMailID: 20170619122254epcas5p49c12385e361c09d50eb4d0dfea71f41a X-RootMTR: 20170619122254epcas5p49c12385e361c09d50eb4d0dfea71f41a References: Subject: [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: Mon, 19 Jun 2017 12:21:38 -0000 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/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