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 99ED0C433FE for ; Wed, 5 Oct 2022 15:26:55 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3527B84E3B; Wed, 5 Oct 2022 17:26:38 +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="x7b8EYvj"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 37B7984E0F; Wed, 5 Oct 2022 17:26:34 +0200 (CEST) Received: from mail-ed1-x52e.google.com (mail-ed1-x52e.google.com [IPv6:2a00:1450:4864:20::52e]) (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 8863284D96 for ; Wed, 5 Oct 2022 17:26:29 +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-x52e.google.com with SMTP id y8so23478738edc.10 for ; Wed, 05 Oct 2022 08:26:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=6MrOgdaTi6CwJiEdBgg5+2Zmcf+m2ZcJoVQWPPkt+hk=; b=x7b8EYvjbrloLivuQYEroYWGoK8ybWQiKrv/vgjvpAkvl0NAz10g1mLO6Icjk1jmRT UG+wSGT6UUc9g+JvcqpRAd8S5aa2U1SjaEKmpRadl3WEbfoLvJHozgXi0GEBmG8SLbn5 LmFCbtSxtsStOyT1BgBjD8Hu+1LupPnbyA/J3jGKi6296+wI9eRvmGklQTiQ/VK7S+YD M7lZ4/r8WZZ9BvPrgIZTT3roybpao3YsUsg+P6UzRqHngJgjlu7+OhNx7EYCOYb3XLha 5bW7i8WKznxRxOGCD0hZcqdakDy3c5fcZcyXbKZJBJXMquSSnqBSYlFrZE8hAhyRKiq5 x/dQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=6MrOgdaTi6CwJiEdBgg5+2Zmcf+m2ZcJoVQWPPkt+hk=; b=d+wy2YUUM1PNHpEiQeFdfEr2mfBSbhUV58xKWp2aDq18+aiW6ceGO/dIURnnZFZVZq zCw35LUTOGZ63O6VlkWj4bHQs3/kCXGs/Je8B2HRhyiZHjTE4K5xS+5eMQqVfllPiuvR 8oOi1N7XASIV4f9Zby09zLGISWxCI/trKLbtqcKEwcNNh3BRDx8ajHcbUd4uSYrVlisR mElfkeYbbed4LH/yeOZvTNijli0fAIVUeQoAgisqycKgPFU1N4jr+QXBDe0aDw6imqpt tXCqFBpSmdsJgGjLoJfXbtm9rfhsvR3nDht0/FWfWP08YoTrsEBHdOzD/Ds6ILUFz8dt 4RtA== X-Gm-Message-State: ACrzQf37c78yjdwsqAUpsiKjcSHtqkNTKBP12XTIgT6ZVLB5G6c+HfM6 6MtHuF9TvE/V/3XyMPRv6+0l/A== X-Google-Smtp-Source: AMsMyM758jrE1zDKZUFznku/+Q38x7e4HMI2XBuK0o2XU1jVYojU5uJHx9iwsJ6fgs2pz3vkcY4QdQ== X-Received: by 2002:a05:6402:448b:b0:43b:5ec6:8863 with SMTP id er11-20020a056402448b00b0043b5ec68863mr260201edb.377.1664983589073; Wed, 05 Oct 2022 08:26:29 -0700 (PDT) Received: from hades.. (ppp046103015185.access.hol.gr. [46.103.15.185]) by smtp.gmail.com with ESMTPSA id n15-20020aa7c78f000000b00458d50b4a24sm3918815eds.96.2022.10.05.08.26.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Oct 2022 08:26:28 -0700 (PDT) From: Ilias Apalodimas To: xypron.glpk@gmx.de Cc: Ilias Apalodimas , u-boot@lists.denx.de Subject: [RFC PATCH 2/2] cmd: replace efi_create_handle/add_protocol with InstallMultipleProtocol Date: Wed, 5 Oct 2022 18:26:02 +0300 Message-Id: <20221005152603.3085754-3-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221005152603.3085754-1-ilias.apalodimas@linaro.org> References: <20221005152603.3085754-1-ilias.apalodimas@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 In general handles should only be deleted if the last remaining protocol is removed. Instead of explicitly calling efi_create_handle -> efi_add_protocol -> efi_delete_handle which blindly removes all protocols from a handle before removing it, use InstallMultiple/UninstallMultiple which adheres to the EFI spec and only deletes a handle if there are no additional protocols present Signed-off-by: Ilias Apalodimas --- cmd/bootefi.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/cmd/bootefi.c b/cmd/bootefi.c index 3041873afbbc..4ab68868cc7e 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -509,12 +509,9 @@ efi_status_t efi_run_image(void *source_buffer, efi_uintn_t source_size) * Make sure that device for device_path exist * in load_image(). Otherwise, shell and grub will fail. */ - ret = efi_create_handle(&mem_handle); - if (ret != EFI_SUCCESS) - goto out; - - ret = efi_add_protocol(mem_handle, &efi_guid_device_path, - file_path); + ret = efi_install_multiple_protocol_interfaces(&mem_handle, + &efi_guid_device_path, + file_path, NULL); if (ret != EFI_SUCCESS) goto out; msg_path = file_path; @@ -542,7 +539,9 @@ efi_status_t efi_run_image(void *source_buffer, efi_uintn_t source_size) ret = do_bootefi_exec(handle, load_options); out: - efi_delete_handle(mem_handle); + efi_uninstall_multiple_protocol_interfaces(mem_handle, + &efi_guid_device_path, + file_path, NULL); efi_free_pool(file_path); return ret; } -- 2.34.1