From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AB74DC433F5 for ; Tue, 11 Oct 2022 00:49:54 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A5F0D84ADF; Tue, 11 Oct 2022 02:49:51 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="qhQoRdPU"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id CF40184A73; Tue, 11 Oct 2022 02:49:49 +0200 (CEST) Received: from mail-pg1-x529.google.com (mail-pg1-x529.google.com [IPv6:2607:f8b0:4864:20::529]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 9CCAA84C8E for ; Tue, 11 Oct 2022 02:49:45 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=takahiro.akashi@linaro.org Received: by mail-pg1-x529.google.com with SMTP id q9so11543048pgq.8 for ; Mon, 10 Oct 2022 17:49:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:cc:to:from:date:from:to:cc :subject:date:message-id:reply-to; bh=jIyRrkkmo/9bMvqG0njQCtqrMJmPiqKG0wD23537quM=; b=qhQoRdPU8iUw1yugDXas8rDiVWzY825Hh2hPl+CZmJL42aMpycaTU8rL1XcstiBRC2 giVujqzIIgOinDG29nkP6y3bmw/HI4ISQLfGI/Tuo8q8h1CQ8X1RjST+30ImT8pHGTUM gc8LYCu5FXmTvHj0lz3JSNzLZbMZdqE+BNDnIv3Wj7Sinc+NrwNR3F3yhmvHoSjjZXvA Uy2OiI8lSBCacyg3fAiXcCUnCO6PMoDKAL08SYQ9hNVr8XPxAUABFGeprGcvCEYM696J c2lnAr/WqcfVv05p3h+GtJEc6jYI2z+Ok+QEBDzg32zSsuyivuhmZXOFDZONLbJfy5nH Pmhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=jIyRrkkmo/9bMvqG0njQCtqrMJmPiqKG0wD23537quM=; b=caa102DFf0bPBVZ8WhMA1Gp9NoXMaD0CR9hc8esMRIXL18FopIf7qSenCaqq4sF/IF Tc8E7ZNCJa+WOddKFFX6zl6bbpiFHEgPXMjC6shfgEXCCn/QumkSYRgNfez4lvHaaHV3 8nPpGHYJ1uMJjj9t10bzCzOWG2rXqQR5PeE/Df9obIUqu0/qe6IN2cxe1gNAepvfwHdi 2VXTKld4FTgzcet5HiXcEHldUkfio85DoG0BWDHb4xHCJNa0w0A3siYqSz7/+wDakNpJ thkwJmZ7rRjaLWFQdON8gf2cnEzrz8Qr0OcUV+CPEc6Sq7GN3k3KWHsxwv9jlv02rXx/ Uu1A== X-Gm-Message-State: ACrzQf2LLLv9G9d5f1PmHpAJ2Fdw6bEKIrVVdaJQXlLARpu4oYd/+Gs8 sZ5PrY0tRUk49fixJvX3CtvShQ== X-Google-Smtp-Source: AMsMyM696Z07E/3jACyncOQ4v9SM1bxRrMhAemmHzayOUKrhzFr+bdrEFXNxwnkV6PPCYK2jUdXspA== X-Received: by 2002:a63:1450:0:b0:439:3806:9b91 with SMTP id 16-20020a631450000000b0043938069b91mr18794788pgu.407.1665449383784; Mon, 10 Oct 2022 17:49:43 -0700 (PDT) Received: from laputa ([2400:4050:c3e1:100:e18:1c25:9aae:c323]) by smtp.gmail.com with ESMTPSA id x12-20020a170902ec8c00b0017f7c4e2604sm7257325plg.296.2022.10.10.17.49.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Oct 2022 17:49:42 -0700 (PDT) Date: Tue, 11 Oct 2022 09:49:39 +0900 From: AKASHI Takahiro To: Heinrich Schuchardt Cc: Ilias Apalodimas , u-boot@lists.denx.de Subject: Re: [PATCH 1/1] efi_loader: CloseProtocol in efi_fmp_find Message-ID: <20221011004939.GA39168@laputa> Mail-Followup-To: AKASHI Takahiro , Heinrich Schuchardt , Ilias Apalodimas , u-boot@lists.denx.de References: <20221007140623.167909-1-heinrich.schuchardt@canonical.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221007140623.167909-1-heinrich.schuchardt@canonical.com> X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean The commit message is not accurate. On Fri, Oct 07, 2022 at 04:06:23PM +0200, Heinrich Schuchardt wrote: > The CloseProtocol() boot service requires a handle as first argument. > Passing the protocol interface is incorrect. Correct, but > CloseProtocol() only has an effect if called with a non-zero value for > agent_handle. HandleProtocol() uses an opaque agent_handle when invoking > OpenProtocol() (currently NULL). No. OpenProtocol() is called with efi_root as an agent handle. So, calling CloseProtocol() is a right thing at the end. > Therefore HandleProtocol() should be > avoided. > > * Replace the LocateHandle() call by efi_search_protocol(). LocateHandle() -> efi_handle_protocol() So you could have fixed this way: EFI_CALL(efi_close_protocol(handle, ..., &efi_root, NULL); I preferred to use EFI_CALL() over this file as you can see. -Takahiro Akashi > * Remove the CloseProtocol() call. > > Fixes: 8d99026f0697 ("efi_loader: capsule: support firmware update") > Signed-off-by: Heinrich Schuchardt > --- > lib/efi_loader/efi_capsule.c | 14 ++++++-------- > 1 file changed, 6 insertions(+), 8 deletions(-) > > diff --git a/lib/efi_loader/efi_capsule.c b/lib/efi_loader/efi_capsule.c > index b6bd2d6af8..397e393a18 100644 > --- a/lib/efi_loader/efi_capsule.c > +++ b/lib/efi_loader/efi_capsule.c > @@ -159,12 +159,14 @@ efi_fmp_find(efi_guid_t *image_type, u8 image_index, u64 instance, > efi_status_t ret; > > for (i = 0, handle = handles; i < no_handles; i++, handle++) { > - ret = EFI_CALL(efi_handle_protocol( > - *handle, > - &efi_guid_firmware_management_protocol, > - (void **)&fmp)); > + struct efi_handler *fmp_handler; > + > + ret = efi_search_protocol( > + *handle, &efi_guid_firmware_management_protocol, > + &fmp_handler); > if (ret != EFI_SUCCESS) > continue; > + fmp = fmp_handler->protocol_interface; > > /* get device's image info */ > info_size = 0; > @@ -215,10 +217,6 @@ efi_fmp_find(efi_guid_t *image_type, u8 image_index, u64 instance, > skip: > efi_free_pool(package_version_name); > free(image_info); > - EFI_CALL(efi_close_protocol( > - (efi_handle_t)fmp, > - &efi_guid_firmware_management_protocol, > - NULL, NULL)); > if (found) > return fmp; > } > -- > 2.37.2 >