From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM04-CO1-obe.outbound.protection.outlook.com (mail-oln040092010024.outbound.protection.outlook.com [40.92.10.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 5D7E821A00AC9 for ; Wed, 28 Jun 2017 11:09:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=7pyJfNOlJOKECtvqTwqbwypSb1uJUCimL4lhRALe76Q=; b=ZTn2HVz5t6g7GTK1MIUVyyKX2h80R1dVYxrVn41DizzjDdHzKQLZB9qQndM3uV6gwhCFgzuodQcWqccIrDYd8eV+goqNnk0h7HrLbtN3WogUSHy7cLwDU3YU+EYQ2F4m/Lwf/9jOjkOcqfvSQgQxWnNfprNGtcl8TGzJrXTgpDZnUHOkFbhMuSkS/8jXDjGoHBhk4KBCXKMuK0wNydg7U2LezGNQqoINaP9Soo4BI0lciwDitlTURAUJPg4EHfw1fe9ZrrB6Hg2VTTCeY5+tS+buydXuPxgx/TXUKJ9hiUnIkZLnrvg5P7cx90z5XM7XnftQy9umiHVU+lbKsrS5SQ== Received: from CO1NAM04FT006.eop-NAM04.prod.protection.outlook.com (10.152.90.54) by CO1NAM04HT120.eop-NAM04.prod.protection.outlook.com (10.152.90.188) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.1199.9; Wed, 28 Jun 2017 18:10:56 +0000 Received: from DM5PR11MB1578.namprd11.prod.outlook.com (10.152.90.55) by CO1NAM04FT006.mail.protection.outlook.com (10.152.90.104) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1199.9 via Frontend Transport; Wed, 28 Jun 2017 18:10:56 +0000 Received: from DM5PR11MB1578.namprd11.prod.outlook.com ([10.172.37.22]) by DM5PR11MB1578.namprd11.prod.outlook.com ([10.172.37.22]) with mapi id 15.01.1220.014; Wed, 28 Jun 2017 18:10:56 +0000 From: Amit kumar To: Star Zeng , "edk2-devel@lists.01.org" CC: Liming Gao , Gabriel Somlo , Michael D Kinney , Laszlo Ersek Thread-Topic: [edk2] [PATCH V5] MdeModulePkg/DxeCore: Fixed Interface returned by CoreOpenProtocol Thread-Index: AQHS8BGqbkyHW/V6TUGc82VnZHUTvKI6k4xl Date: Wed, 28 Jun 2017 18:10:56 +0000 Message-ID: References: <1498656170-184428-1-git-send-email-star.zeng@intel.com> In-Reply-To: <1498656170-184428-1-git-send-email-star.zeng@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=hotmail.com; x-incomingtopheadermarker: OriginalChecksum:52FD24CEADF08DF8EC47AA6ACCBF5F8E11593E0499E423D56392CD09565ECE40; UpperCasedChecksum:DBBA36713DD41D42C906D1AB91E0A95532EA7B7CDB986F4E8790CF7687A287A9; SizeAsReceived:7485; Count:46 x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [wLsTGOwL6f4VLXs9lWiDd2EEh/JOSb1x] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; CO1NAM04HT120; 7:ZYOZvlYY8xnQl0wK0JsVpbRatYIc40BOh02UrnC5ntvVIKv0mABdwgC/s6Dgy3rsgm/YM8X3Bc7YwdbQay8/3jnN8HU9Lt19r9XJFN9VvxrqBmfHYHROz4jya8YCvSSFrScRP0av4pj/7Xx2QKKjE7eVGRqSlewZft1HWA88DT7oxb+cL1NvR/6j6pWH0ob2euThILZiRorLI4weLMvM49c9FHZ4WKoUAae9lzx6o3OjavNnXeOJeOxmD3GmPdE3FBw8dLcP9jVWjGb4goGgWnuj+vtSZtRKDxEcO20lITl/x169zWxmmgxW1k02xV7nWARtTV8zfIAhz0XUfxN37Omc35FXheUVo0uno2bYLMKFwxNAURV/UKXkXeU1xmJ7SaficEvbq3j/Yp9Au+YWnLhtieC5n9xKPs3iXlqgTsxKpROzRGSEUKxRRh613JRfIPnxQpls+ZQNOrlf9PfpLBknnXynYMfSkbGosneXgfPKikk8UH1ZRW79YjYdmTZtv05Sj+wnQxpYyIX4BVwlFBZ3Z9FQEaccrltWl8zC3G2Y1BnFgjQGWR+oBsgKGm9TcMNKQUy31tcNkE+c+ldbjPFcdPUoAzycpllxz7Rq2BAhqoyPieb+WcH3WHfcIbAIXsosHF3rqyPpGnl2OfNamaFX+FU7jyqc+eZyb9esIX7qw9S47pnNcg8fLBsguYEZmxHOVZkjmPdb6Ifl6BI/IL8/4owbujCvblPORIEAfnFq9gOLCZH8AIfoS35M+aGyuVH/4nKo11sP43UHUv5zwQ== x-incomingheadercount: 46 x-eopattributedmessage: 0 x-forefront-antispam-report: EFV:NLI; SFV:NSPM; SFS:(7070007)(98901004); DIR:OUT; SFP:1901; SCL:1; SRVR:CO1NAM04HT120; H:DM5PR11MB1578.namprd11.prod.outlook.com; FPR:; SPF:None; LANG:en; x-ms-office365-filtering-correlation-id: 8e303a4f-d6e5-4382-8cb9-08d4be5105bd x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(300000502095)(300135100095)(22001)(300000503095)(300135400095)(201702061074)(5061506573)(5061507331)(1603103135)(2017031320274)(2017031324274)(2017031323274)(2017031322274)(1601125374)(1603101448)(1701031045)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:CO1NAM04HT120; x-ms-traffictypediagnostic: CO1NAM04HT120: x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(444000031); SRVR:CO1NAM04HT120; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:CO1NAM04HT120; x-forefront-prvs: 03524FBD26 spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: hotmail.com X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Jun 2017 18:10:56.2037 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1NAM04HT120 X-Content-Filtered-By: Mailman/MimeDel 2.1.22 Subject: Re: [PATCH V5] 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: Wed, 28 Jun 2017 18:09:25 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable sorry, wrong thread ________________________________ From: edk2-devel on behalf of Star Zeng <= star.zeng@intel.com> Sent: Wednesday, June 28, 2017 6:52:50 PM To: edk2-devel@lists.01.org Cc: Liming Gao; Gabriel Somlo; Michael D Kinney; Laszlo Ersek; Star Zeng Subject: [edk2] [PATCH V5] MdeModulePkg/DxeCore: Fixed Interface returned b= y CoreOpenProtocol From: Amit Kumar Change since v4: Revise the patch based on V4 sent by Amit Kumar 1) Only return the corresponding protocol interface in *Interface if the return status is EFI_SUCCESS or EFI_ALREADY_STARTED. 2) Interface is returned unmodified for all error conditions except EFI_UNSUPPORTED and EFI_ALREADY_STARTED, NULL will be returned in *Interface when EFI_UNSUPPORTED and Attributes is not EFI_OPEN_PROTOCOL_TEST_PROTOCOL, the protocol interface will be returned in *Interface when EFI_ALREADY_STARTED. Change since v3: 1) Fixed issue when Attributes =3D EFI_OPEN_PROTOCOL_TEST_PROTOCOL and Inteface =3D 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 Cc: Laszlo Ersek Cc: Amit Kumar Cc: Michael D Kinney Cc: Liming Gao Cc: Gabriel Somlo Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Amit Kumar Signed-off-by: Star Zeng --- MdeModulePkg/Core/Dxe/Hand/Handle.c | 36 +++++++++++++++++++++++----------= --- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/MdeModulePkg/Core/Dxe/Hand/Handle.c b/MdeModulePkg/Core/Dxe/Ha= nd/Handle.c index 59b89148c8f0..3862a3876f4a 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 !=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; } // @@ -1078,12 +1074,6 @@ CoreOpenProtocol ( goto Done; } - // - // 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; ByDriver =3D FALSE; @@ -1177,8 +1167,28 @@ CoreOpenProtocol ( } Done: + + if (Attributes !=3D EFI_OPEN_PROTOCOL_TEST_PROTOCOL) { + // + // Keep Interface unmodified in case of any Error + // except EFI_ALREADY_STARTED and EFI_UNSUPPORTED. + // + if (!EFI_ERROR (Status) || Status =3D=3D EFI_ALREADY_STARTED) { + // + // EFI_ALREADY_STARTED is not an error for bus driver. + // Return the corresponding protocol interface. + // + *Interface =3D Prot->Interface; + } else if (Status =3D=3D EFI_UNSUPPORTED) { + // + // Return NULL Interface if Unsupported Protocol. + // + *Interface =3D NULL; + } + } + // - // Done. Release the database lock are return + // Done. Release the database lock and return // CoreReleaseProtocolLock (); return Status; -- 2.7.0.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel