From patchwork Wed Oct 5 15:26:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 612536 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp891690pvb; Wed, 5 Oct 2022 08:26:55 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5LJiYZPRJYEAuVP/EayIsRL/YBLoBWcF/pCNjX9MEAgEN0zbn0usNZh35GSsVLloo4Jkmv X-Received: by 2002:a50:9510:0:b0:453:dded:60e with SMTP id u16-20020a509510000000b00453dded060emr311695eda.204.1664983615168; Wed, 05 Oct 2022 08:26:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664983615; cv=none; d=google.com; s=arc-20160816; b=q6icZnH+rutsUOsbpLPjpd+yQSmg/ABHuFVOC1DIkLarqmxGQ0mZRSAk4kFvfHFf6I PMot5zaklehf3BueATm8YhHyAvjVu892CcdtO+ML22I8u7mtXAS41ze6XqKtlahFcNvC tD/P3g31LL1sfi98qaEYlBtIOJk6OO5RvM2i0ajnumzpZQs/2fhL6gtLAXfpJuedayrw zMKg5sSMmkkvOe3QpGaf1GznzZL9Yvi6eNyxqNHSe61rCoST9xATlVyIC8FvrPveK1sa MTxVrUeMjVX2ONpXMhaVHLuGpy+AiVl60Jws9/HaGgb7dJeN8FQF2HH7v0rdb9zPS7JX Ix+A== 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:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=6MrOgdaTi6CwJiEdBgg5+2Zmcf+m2ZcJoVQWPPkt+hk=; b=WhUQJqknIuiWkrfWbKdrWI8tClqM/pVZygxz+f14yS41/KV6140LbdJjkM3CfZt0SQ 56xEs/CoLLNCBpAvU8fy78S5VbkOxjtEFW+9BW/MnuLDzEoeMg0FqgrFJizac33VjpMA 5dYMVJ5qk7ResXNOu20k+GsaM+z8A358yxiPiKw3shaPBDFWOmUR6nsQk/AiL4vdfi8X B/Mpzc5Pk67dk4+bYvJMoP4YSsHzs7hiQC0PiLvws3idEzAeDykmAwrGXBy6uPSeMPTB qWTZ7fDHKfO5W5IkMrntvnxNqwvd78sLNeOXZocDzzefUQouNZvXeCWTgeG47WZ6iwIn ni+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=x7b8EYvj; 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 hc19-20020a170907169300b00774195db4e7si15208628ejc.117.2022.10.05.08.26.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Oct 2022 08:26:55 -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=x7b8EYvj; 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 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) 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-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-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 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; }