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 5F64AC433F5 for ; Fri, 7 Oct 2022 17:05:54 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D275984E81; Fri, 7 Oct 2022 19:05: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="ngRQfgu9"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E488584E82; Fri, 7 Oct 2022 19:05:49 +0200 (CEST) Received: from mail-ed1-x532.google.com (mail-ed1-x532.google.com [IPv6:2a00:1450:4864:20::532]) (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 0A94384E7F for ; Fri, 7 Oct 2022 19:05:47 +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=ilias.apalodimas@linaro.org Received: by mail-ed1-x532.google.com with SMTP id s30so7932750eds.1 for ; Fri, 07 Oct 2022 10:05:47 -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:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=cRr9tjUco8hiLfIgEHn2QCpnEksXHa6ycEexSwis7og=; b=ngRQfgu9Dd0aOJL/fD+LSmZpcAkSQkT0+5lNrtyKFJnuuN/4sj6VGLvVE9BcizyTTx TlPup4ln4hU4keA4N/+jy/CzKfIlGbURL11OmhvTly4oULvDOXvSNNWNwh1mnKvN++17 YrZNpsrIQ94Hx0iMntkqu3KazhCGT3+k7hCH/KtCNihimsgN4I4K7iYAaTltK3FGUi6a 4QQiYDes3xJQPsjGgYtAvWzKUeTzQF9DjEYvVWSvxtkHM9juLacdbzCV7Js7yBpng4bu f6md1GywyLrSaZ7/vRXqsdU3C0MJI2iO5EshAau4OUUlPbu+Tb1n8Vv937jb1NWErTU7 T6cw== 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:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=cRr9tjUco8hiLfIgEHn2QCpnEksXHa6ycEexSwis7og=; b=02hjQVhOxh/prlC15n/ihnrp/XrXwMq/lQBstWGGUSQeBTng77XtbyRtPqwEWRH3+V 0pLFteByyzyDQBF0Q9LDL6r7e6rVU/J9UMhNnCQhhs6e8CK33jCZAD+wHvtkPEOMbuBW VOLG1360964bF/p/dzq9O/DIzyYEHbZTjcyGoM/mNKDX7BHcfDFsXoHNTqhDH4KXebT9 IJSvY1QlLyJmmDbJDDsJ49ZIBuo3V9YaP2qkRHXm/LLLumbKNSEwhLqnvODdesUcIPGk dOmE07Jxi3v4EIigeUOF3ceHCRPn5EC4+SCK/31pFEyFYPNm9E2Mlx7T9nsoMqmF2WzS V1qw== X-Gm-Message-State: ACrzQf13dtZAT1jjxNMXQnLVd5AN2K3QbkAIFnf+DcXovBFnju9Jh5zv InNmsH7o3B3fe5Ew0esKdXpL4LdrTGNanA== X-Google-Smtp-Source: AMsMyM7XZwdw9rkWa3L2ZBjjPwqVed44iFTne3SSZtL9IiyMH93ZuiuLgcamZOTLqzwAgF5JaTinvw== X-Received: by 2002:a50:fd16:0:b0:458:bf43:8dc7 with SMTP id i22-20020a50fd16000000b00458bf438dc7mr5430403eds.400.1665162346588; Fri, 07 Oct 2022 10:05:46 -0700 (PDT) Received: from hades (ppp046103015185.access.hol.gr. [46.103.15.185]) by smtp.gmail.com with ESMTPSA id ku20-20020a170907789400b0078cb06c2ef9sm1529066ejc.8.2022.10.07.10.05.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Oct 2022 10:05:45 -0700 (PDT) Date: Fri, 7 Oct 2022 20:05:43 +0300 From: Ilias Apalodimas To: Heinrich Schuchardt Cc: Masahisa Kojima , u-boot@lists.denx.de Subject: Re: [PATCH 1/1] efi_loader: CloseProtocol in tcg2_measure_gpt_data Message-ID: References: <20221007133845.123352-1-heinrich.schuchardt@canonical.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221007133845.123352-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 On Fri, Oct 07, 2022 at 03:38:45PM +0200, Heinrich Schuchardt wrote: > The CloseProtocol() boot service requires a handle as first argument. > Passing the protocol interface is incorrect. > > 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). Therefore HandleProtocol() should be > avoided. > > * Replace the LocateHandle() call by efi_search_protocol(). > * Remove the CloseProtocol() call. > * Remove a superfluous goto. > > Fixes: ce3dbc5d080d ("efi_loader: add UEFI GPT measurement") > Signed-off-by: Heinrich Schuchardt > --- > lib/efi_loader/efi_tcg2.c | 10 +++------- > 1 file changed, 3 insertions(+), 7 deletions(-) > > diff --git a/lib/efi_loader/efi_tcg2.c b/lib/efi_loader/efi_tcg2.c > index 99ec3a5486..a525ebf75b 100644 > --- a/lib/efi_loader/efi_tcg2.c > +++ b/lib/efi_loader/efi_tcg2.c > @@ -2053,7 +2053,7 @@ tcg2_measure_gpt_data(struct udevice *dev, > { > efi_status_t ret; > efi_handle_t handle; > - struct efi_handler *dp_handler; > + struct efi_handler *dp_handler, *io_handler; > struct efi_device_path *orig_device_path; > struct efi_device_path *device_path; > struct efi_device_path *dp; > @@ -2098,10 +2098,10 @@ tcg2_measure_gpt_data(struct udevice *dev, > if (ret != EFI_SUCCESS) > goto out1; > > - ret = EFI_CALL(efi_handle_protocol(handle, > - &efi_block_io_guid, (void **)&block_io)); > + ret = efi_search_protocol(handle, &efi_block_io_guid, &io_handler); > if (ret != EFI_SUCCESS) > goto out1; > + block_io = io_handler->protocol_interface; > > gpt_h = memalign(block_io->media->io_align, block_io->media->block_size); > if (!gpt_h) { > @@ -2164,12 +2164,8 @@ tcg2_measure_gpt_data(struct udevice *dev, > } > > ret = tcg2_measure_event(dev, 5, EV_EFI_GPT_EVENT, event_size, (u8 *)event); > - if (ret != EFI_SUCCESS) > - goto out2; > > out2: > - EFI_CALL(efi_close_protocol((efi_handle_t)block_io, &efi_block_io_guid, > - NULL, NULL)); > free(gpt_h); > free(entry); > free(event); > -- > 2.37.2 > Reviewed-by: Ilias Apalodimas