From nobody Fri May 3 11:49:49 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zoho.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1498656182467776.191253406075; Wed, 28 Jun 2017 06:23:02 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id E11CC21BBC412; Wed, 28 Jun 2017 06:21:24 -0700 (PDT) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) (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 79B9221BBC40F for ; Wed, 28 Jun 2017 06:21:23 -0700 (PDT) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga104.jf.intel.com with ESMTP; 28 Jun 2017 06:22:54 -0700 Received: from shwdeopenpsi068.ccr.corp.intel.com ([10.239.9.2]) by fmsmga002.fm.intel.com with ESMTP; 28 Jun 2017 06:22:52 -0700 X-Original-To: edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.40,275,1496127600"; d="scan'208";a="1187990292" From: Star Zeng To: edk2-devel@lists.01.org Date: Wed, 28 Jun 2017 21:22:50 +0800 Message-Id: <1498656170-184428-1-git-send-email-star.zeng@intel.com> X-Mailer: git-send-email 2.7.0.windows.1 Subject: [edk2] [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: , Cc: Liming Gao , Gabriel Somlo , Michael D Kinney , Laszlo Ersek , Star Zeng MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Laszlo Ersek Tested-by: Gabriel Somlo Tested-by: Laszlo Ersek --- 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; } =20 // @@ -1078,12 +1074,6 @@ CoreOpenProtocol ( 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; @@ -1177,8 +1167,28 @@ CoreOpenProtocol ( } =20 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.=20 + // + *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; --=20 2.7.0.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel