From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (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 5A25021CB57DC for ; Wed, 28 Jun 2017 07:12:17 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 65F9D30315A; Wed, 28 Jun 2017 14:13:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 65F9D30315A Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=lersek@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 65F9D30315A Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-57.phx2.redhat.com [10.3.116.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id CAE1D89E6A; Wed, 28 Jun 2017 14:13:46 +0000 (UTC) To: Star Zeng , edk2-devel@lists.01.org Cc: Amit Kumar , Michael D Kinney , Liming Gao , Gabriel Somlo References: <1498656170-184428-1-git-send-email-star.zeng@intel.com> From: Laszlo Ersek Message-ID: Date: Wed, 28 Jun 2017 16:13:45 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <1498656170-184428-1-git-send-email-star.zeng@intel.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Wed, 28 Jun 2017 14:13:48 +0000 (UTC) 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 14:12:17 -0000 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit On 06/28/17 15:22, Star Zeng wrote: > 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 = 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 > > 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(-) Reviewed-by: Laszlo Ersek Tested-by: Laszlo Ersek Thanks! Laszlo > diff --git a/MdeModulePkg/Core/Dxe/Hand/Handle.c b/MdeModulePkg/Core/Dxe/Hand/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 != 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; > } > > // > @@ -1078,12 +1074,6 @@ CoreOpenProtocol ( > 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,8 +1167,28 @@ CoreOpenProtocol ( > } > > Done: > + > + if (Attributes != 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 == EFI_ALREADY_STARTED) { > + // > + // EFI_ALREADY_STARTED is not an error for bus driver. > + // Return the corresponding protocol interface. > + // > + *Interface = Prot->Interface; > + } else if (Status == EFI_UNSUPPORTED) { > + // > + // Return NULL Interface if Unsupported Protocol. > + // > + *Interface = NULL; > + } > + } > + > // > - // Done. Release the database lock are return > + // Done. Release the database lock and return > // > CoreReleaseProtocolLock (); > return Status; >