From patchwork Sun Oct 16 08:36:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 615423 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp1308682pvb; Sun, 16 Oct 2022 01:36:50 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4y3a5dxIW9TOhKrsC+FISyBqr9kF6J0hJDwG5gAdc61WbE0fWiOQ9yr51Plke0FDbgk14Z X-Received: by 2002:a05:6402:2683:b0:45d:3c44:dad4 with SMTP id w3-20020a056402268300b0045d3c44dad4mr5350227edd.124.1665909410467; Sun, 16 Oct 2022 01:36:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665909410; cv=none; d=google.com; s=arc-20160816; b=Lk/YrkQp7XhOxg4tZlkegAONQHEEhKKZU25OQ5OnGTEOWFeVD+J10VF8hBTbC3y70u kHrjFSfVL2UUU8h/3oU9KTjlH4MXJwxO8aUdBmElHG3VihdMLgR0DLO6pluseFQmCW3o jsMGiFTLRjGkAXVPeCcnwK41FpFgAMSTy4JuM12yS+AuxPutLopLNQiyW3UJDMJCUpeD fh96RUm3AvTMs1cKCy4FUvUVcX1aEYk7aHhwQOSB3bFFxZw8HqLT2rJkMdazUBLxYc3q 0M0s1cX77eO2suwOgA9Qf3dvb11rGHSX7/A2TKtGWr7+nEy6n0wtncV+vIR5nCPeA+Vh O7mA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=z0W8K+aw40qznvBVR+s/Yg5anjl1E/pcw5GHhwxIPgU=; b=Nv4ZDUcbUnOF/S3Q4ikWVmy48WhLBJ07HVvOt1HZLAq5Bj++eQiEGl6m7wW+DQ/b4E djxEj3ZMNXmlYLhHN58KFMEHNVafZZQVRgRpgfUUm2kzysjgEYIPZ3CoirzyjJuW8Vlw ZGCCTPps58lPQlEhx0swl/9BRBM8JHvAL/7/VxfQbSwPo6hD6gLPTDqntKo5TKUdmM5P h5HPWZB1BYrcp1Qgk1OTIDO1qjJKkt30aTHrlDbCoYQ/YQpFYzQ0dsOETYEckDpJqDM6 BNuSAJzUVxzK8QMgLsmD/c2HKVUIF9anSv7nIv3Q3YQ726P+UxIcQw1TvYFn+lWWx08L SMHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Sv/r4Rcf"; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id hu9-20020a170907a08900b0078dcd448f99si6041885ejc.855.2022.10.16.01.36.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 16 Oct 2022 01:36:50 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Sv/r4Rcf"; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D5B3E84CBC; Sun, 16 Oct 2022 10:36:46 +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="Sv/r4Rcf"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6D2E584D39; Sun, 16 Oct 2022 10:36:44 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) (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 9AD4984C60 for ; Sun, 16 Oct 2022 10:36:41 +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-wr1-x432.google.com with SMTP id a3so14021507wrt.0 for ; Sun, 16 Oct 2022 01:36:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=z0W8K+aw40qznvBVR+s/Yg5anjl1E/pcw5GHhwxIPgU=; b=Sv/r4RcfezubJLj+fVNEN5f/Ik4XaU5TzBe9ckjLymyTL/aPGYOr4NUqfPumEf5f/l o+V9n0m3N3kh3bWv1xJu4MvMQzFSerd4Xog31A/OFxvf8vFkConvM+bvhcGyaFoPqgpx UpWHC15RzLG9JvSPgE2ZecqkuCEkuWxYujmttmYILOxksjx+IM23qPWj0OV58juu5TGd t6VOPj8zI1YDS/2Oz26PBmPSMw4v1pcTPVp+nR8fdcmbF/P30GkXR9wuAp/WNv+/yWEc ZKLzFP4nLftm11hZG+coW8sffBPNsvfzzs86cxjRsE+jd0W7xjEWFjlKaMQXQshlolDc +7Bw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=z0W8K+aw40qznvBVR+s/Yg5anjl1E/pcw5GHhwxIPgU=; b=mcBg3sLje9szMGwhWfx90peS/s+8XOg6j/VcPL48czoSPx9QagItD0hPrEtg5SQwDD naaxX2bzKn4ejFRF4rfaKeLVB9U1gtbFBQCEOSuavq8qxA5gPW1befnfPjQdGWz9p7wd VRADEQmGjDifJT9f7Q175HrDTxfrU3OkS5sGFBJfNMWTPPNY6amAOisUlp0K0ogfp0UQ so6s8kdiA6Krq/Qj0lwo8NEevZkBB0iDvacoOCf9D2PfYrWYRVFPu2mzH/NLGYPk693S I39ZeBvWOa/1d2u3cBsgwss/DJS22reZFdVn/KM+4BfN8fdB/lGwLrAASRJL8oq27FZV vmHg== X-Gm-Message-State: ACrzQf2c/fzDFcKqeioYmDovn84fhw245/Fea08kdreaE0tCb4OPwd3l Yl/s+HEpdr2Ocmi3oErVbjE1JRfSI+wG4g== X-Received: by 2002:adf:f301:0:b0:22e:4479:c1ba with SMTP id i1-20020adff301000000b0022e4479c1bamr3204394wro.133.1665909401061; Sun, 16 Oct 2022 01:36:41 -0700 (PDT) Received: from localhost.localdomain (ppp046103015185.access.hol.gr. [46.103.15.185]) by smtp.gmail.com with ESMTPSA id t18-20020a5d6a52000000b0022af865810esm5709331wrw.75.2022.10.16.01.36.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 16 Oct 2022 01:36:40 -0700 (PDT) From: Ilias Apalodimas To: u-boot@lists.denx.de Cc: heinrich.schuchardt@canonical.com, Ilias Apalodimas , Heinrich Schuchardt Subject: [PATCH v2] efi_loader: remove efi_delete_handle on loadfile2 Date: Sun, 16 Oct 2022 11:36:32 +0300 Message-Id: <20221016083632.239761-1-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.37.2 MIME-Version: 1.0 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 Loadfile2 code is installing two protocols on it's own handle and uses efi_delete_handle() to clean it up on failure(s). However commit 05c4c9e21ae6 ("efi_loader: define internal implementations of install/uninstallmultiple") prepares the ground for us to clean up efi_elete_handle() used in favor of Install/UninstallMultipleProtocol. While at it clean up the non needed void casts to (void *) on the protol installation Signed-off-by: Ilias Apalodimas Reviewed-by: Heinrich Schuchardt --- Changes since v1: - remove non needed void* and while at it clean up the protocol installation as well (from the void*) cmd/bootefi.c | 6 ++++-- include/efi_loader.h | 2 +- lib/efi_loader/efi_load_initrd.c | 19 +++++++++++++++---- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/cmd/bootefi.c b/cmd/bootefi.c index b93c0d3d4c02..2a7d42925d65 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -394,8 +394,10 @@ static efi_status_t do_bootefi_exec(efi_handle_t handle, void *load_options) out: free(load_options); - if (IS_ENABLED(CONFIG_EFI_LOAD_FILE2_INITRD)) - efi_initrd_deregister(); + if (IS_ENABLED(CONFIG_EFI_LOAD_FILE2_INITRD)) { + if (efi_initrd_deregister() != EFI_SUCCESS) + log_err("Failed to remove loadfile2 for initrd\n"); + } /* Control is returned to U-Boot, disable EFI watchdog */ efi_set_watchdog(0); diff --git a/include/efi_loader.h b/include/efi_loader.h index 1bac3f49a3e5..0c6c95ba4641 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -570,7 +570,7 @@ efi_status_t efi_net_register(void); /* Called by bootefi to make the watchdog available */ efi_status_t efi_watchdog_register(void); efi_status_t efi_initrd_register(void); -void efi_initrd_deregister(void); +efi_status_t efi_initrd_deregister(void); /* Called by bootefi to make SMBIOS tables available */ /** * efi_acpi_register() - write out ACPI tables diff --git a/lib/efi_loader/efi_load_initrd.c b/lib/efi_loader/efi_load_initrd.c index 87fde3f88c2b..193433782c24 100644 --- a/lib/efi_loader/efi_load_initrd.c +++ b/lib/efi_loader/efi_load_initrd.c @@ -213,7 +213,7 @@ efi_status_t efi_initrd_register(void) &efi_guid_device_path, &dp_lf2_handle, /* LOAD_FILE2 */ &efi_guid_load_file2_protocol, - (void *)&efi_lf2_protocol, + &efi_lf2_protocol, NULL); return ret; @@ -227,11 +227,22 @@ efi_status_t efi_initrd_register(void) * * Return: status code */ -void efi_initrd_deregister(void) +efi_status_t efi_initrd_deregister(void) { + efi_status_t ret; + if (!efi_initrd_handle) - return; + return EFI_SUCCESS; - efi_delete_handle(efi_initrd_handle); + ret = efi_uninstall_multiple_protocol_interfaces(efi_initrd_handle, + /* initramfs */ + &efi_guid_device_path, + &dp_lf2_handle, + /* LOAD_FILE2 */ + &efi_guid_load_file2_protocol, + &efi_lf2_protocol, + NULL); efi_initrd_handle = NULL; + + return ret; }