From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mailout3.samsung.com (mailout3.samsung.com [203.254.224.33]) (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 3554821A00ACE for ; Fri, 23 Jun 2017 03:07:50 -0700 (PDT) Received: from epcas5p3.samsung.com (unknown [182.195.41.41]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20170623100914epoutp0352af3816e915d1f891d053eb9ab8f35e~KuGFZuVY_3270032700epoutp03U; Fri, 23 Jun 2017 10:09:14 +0000 (GMT) Received: from epsmges5p2.samsung.com (unknown [182.195.42.45]) by epcas5p4.samsung.com (KnoxPortal) with ESMTP id 20170623100914epcas5p447e04f48f6faa5bea0468bcefbc51e1f~KuGFKJ0j03265232652epcas5p4N; Fri, 23 Jun 2017 10:09:14 +0000 (GMT) Received: from epcas5p3.samsung.com ( [182.195.41.41]) by epsmges5p2.samsung.com (EPCPMTA) with SMTP id E8.23.04821.9C8EC495; Fri, 23 Jun 2017 19:09:14 +0900 (KST) Received: from epsmgms2p2.samsung.com (unknown [182.195.42.80]) by epcas5p3.samsung.com (KnoxPortal) with ESMTP id 20170623100913epcas5p3a10353593d6348b5bf3c890e2deaadb7~KuGEm0W9T0203502035epcas5p3D; Fri, 23 Jun 2017 10:09:13 +0000 (GMT) X-AuditID: b6c32a2d-f79866d0000012d5-d5-594ce8c9eebe Received: from epmmp2 ( [203.254.227.17]) by epsmgms2p2.samsung.com (Symantec Messaging Gateway) with SMTP id 88.AA.05071.9C8EC495; Fri, 23 Jun 2017 19:09:13 +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 <0ORZ00GCLW6N3160@mmp2.samsung.com>; Fri, 23 Jun 2017 19:09:13 +0900 (KST) From: Amit Kumar To: edk2-devel@lists.01.org Cc: star.zeng@intel.com, liming.gao@intel.com, michael.d.kinney@intel.com, feng.tian@intel.com, akamit91@hotmail.com, Amit Kumar Date: Fri, 23 Jun 2017 15:39:47 +0530 Message-id: X-Mailer: git-send-email 1.9.1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrOIsWRmVeSWpSXmKPExsWy7bCmpu6pFz6RBntrLPa93slkseXAJlaL PYeOMltM2s1useLeBnaLjo5/TBb7eq0d2D0e95xh81i85yWTR/fsfywefVtWMQawRHHZpKTm ZJalFunbJXBlbFnxjL3gkFDFv4XbGRsYd/B1MXJySAiYSJx4+oEJwhaTuHBvPVsXIxeHkMBS Rom2V+uZIZzPjBKPTh5khOmY09fCDpFYyyixc0UPE4TTxCRx7ccTsFlsAmoSU1sWsYLYIgLS EhuurmcHsZkFZjBKPF5cCmILC0RIHJr9GaiGg4NFQFXi16xckDCvQLTEql0PWCGWyUmcPDaZ FWS+hMARNomf3RdYQOolBGQlNh1ghqhxkVix6DnUC8ISr45vYYewpSS6O2ZB2dUSS7/MZ4SY 08IoMe/jNahme4mLe/4yQdzGJ9H7G+R+kPm8Eh1tQhAlHhJvXx5mg7AdJS4tXwHWKiQQK/H+ 13rWCYzSCxgZVjGKpRYU56anFpsWGOkVJ+YWl+al6yXn525iBEenlu4Oxi8LvA8xCnAwKvHw Jpz1jhRiTSwrrsw9xCjBwawkwnvhmU+kEG9KYmVValF+fFFpTmrxIUZpDhYlcV71ldcihATS E0tSs1NTC1KLYLJMHJxSDYwTDwgr3r/f/cnvauJRK09tXTb+o/qVmhz7lA8HW/oevrolrWS1 3mW7DQv7OBJsWIuqTlUqTj0ZN7lGsCrfWShnnVr1rjSr95knFpwotzt5Snn16k3dt/jWRS65 fsxw5ZuJb9q2sHy5wvRT9a3zC86NZmI368vuvW34v+7zMYY4oVSV3xM+PBJRYinOSDTUYi4q TgQASpoAUcoCAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrILMWRmVeSWpSXmKPExsVy+t9jQd2TL3wiDR5+kLTY93onk8WWA5tY LfYcOspsMWk3u8WKexvYLTo6/jFZ7Ou1dmD3eNxzhs1j8Z6XTB7ds/+xePRtWcUYwBLlZpOR mpiSWqSQmpecn5KZl26rFBripmuhpJCXmJtqqxSh6xsSpKRQlphTCuQZGaABB+cA92AlfbsE t4wtK56xFxwSqvi3cDtjA+MOvi5GTg4JAROJOX0t7BC2mMSFe+vZuhi5OIQEVjNKbP7/jgXC aWGS6P5/kBmkik1ATWJqyyJWEFtEQFpiw9X17CBFzAIzGCX+bDoFlhAWiJA4NPszkM3BwSKg KvFrVi5ImFcgWmLWjiXMENvkJE4em8w6gZF7ASPDKkau1ILi3PTcYqMCo02MwODbdlgrYAdj 07noQ4wCHIxKPLwJZ70jhVgTy4orcw8xSnAwK4nwXnjmEynEm5JYWZValB9fVJqTWnyI0RRo 40RmKdHkfGBk5JXEG5pYGpkYmJkZGhkYmymJ804I/BIhJJCeWJKanZpakFoE08fEwSnVwDgn V/rZ6W8J1jFPD+n8WH7nnNzlWxIPLFe9ZT/horXrzEOetVqZ/vxbipJnvDR+tFFRqNK2cHqG zTuPf16rp9/r+p77U0psMa+DQL/fae/9f1YacWRLLJq0xKqud3VU+2LryNIKv+SjOyxzJ8/m aoha8OqB31nRqbvWz2xdtmVSv09f5pZvF0uVWIozEg21mIuKEwFYOXL8VAIAAA== X-MTR: 20000000000000000@CPGS X-CMS-MailID: 20170623100913epcas5p3a10353593d6348b5bf3c890e2deaadb7 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: 20170623100913epcas5p3a10353593d6348b5bf3c890e2deaadb7 X-RootMTR: 20170623100913epcas5p3a10353593d6348b5bf3c890e2deaadb7 References: Subject: [PATCH V4] 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: Fri, 23 Jun 2017 10:07:50 -0000 Change since v3: 1) Fixed issue when Attributes = EFI_OPEN_PROTOCOL_TEST_PROTOCOL and Inteface = NULL case. [Reported by:star.zeng at intel.com] 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 | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/MdeModulePkg/Core/Dxe/Hand/Handle.c b/MdeModulePkg/Core/Dxe/Hand/Handle.c index 59b8914..fe58b6c 100644 --- a/MdeModulePkg/Core/Dxe/Hand/Handle.c +++ b/MdeModulePkg/Core/Dxe/Hand/Handle.c @@ -1006,12 +1006,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; } // @@ -1075,15 +1071,13 @@ CoreOpenProtocol ( Prot = CoreGetProtocolInterface (UserHandle, Protocol); if (Prot == NULL) { Status = EFI_UNSUPPORTED; + if (Attributes != EFI_OPEN_PROTOCOL_TEST_PROTOCOL){ + //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; @@ -1177,6 +1171,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