From patchwork Thu Oct 6 19:40:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 612925 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp435570pvb; Thu, 6 Oct 2022 12:41:05 -0700 (PDT) X-Google-Smtp-Source: AMsMyM450usonXWYNWwQEdtd+tKNIzzERNI1XRKiGdTnsc7fcLl43IgLG8cyXVtAEJwcaWiyYhVZ X-Received: by 2002:a05:6402:3549:b0:454:414e:a7fd with SMTP id f9-20020a056402354900b00454414ea7fdmr1361386edd.69.1665085265122; Thu, 06 Oct 2022 12:41:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665085265; cv=none; d=google.com; s=arc-20160816; b=B+yCItdyS4JCooiHnOJ0laG72sfVQNNtBrKy7IaX2GsCKmT6QaPkYb+K/ZYxSzHT7e 0KFhn79Q7V/GV0tBk84woQDkj+n0ur4mMQOo+2Wy0E9hGpAajlwhckB9Rp71BVbeolSa z9/KzwAQ8gd+4dgp+m9nFl4OS1BvvJEoCfxy/Y+sN/8VbsxSKYdNhJQekbtzDIg881HY xl1sj4M3r31R6akEXYGfx24zCK4Utmy7P3TMJw2rL1jzXeJ6s8c3e0yysLvOKFf5CB3C Jw15rDutxb3AL6P+6Xl3yIsWQ90q+q6uO1xIdrl8M97FOtjcKLup2Apu3Qq9iQKZWs3f yAbg== 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=zKgX0GuSOleR6TMszLnkxlsjzjpW8+nOg4U1SQF/60Q=; b=mvhChoBtZ4kDkYVM7JnKvfLAMyXUyRaJ+GagZbMHhcaWRXo6LQGF7tZj5BFvxW15W3 7a3KZkiTHbycKZ/H5ksfMGH5+0Kp14AR1V6j2jS/o7VXVwUniI0u/7L4ZRelXX/NGdHR Fskex4qmD5NjQbe03zJMQ5k5njfLgion1O5WXzdmbDGM+jpu1EXHfgW2L7yeRsW9Lhcr ReUntahMmHa8gEtAolQNYTXupxreNH7bqd3G0/YRujEHhCB79JyI0O3fvgMHG8og4OzN uyy4JZxt2U7gGdmghfyrgiOW6sYZq4zxCb4L7xB4/dz3qtUTJB1TtcVk9GXSb/f54O9o ikQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="zDEzi/HC"; 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 i10-20020a05640242ca00b0044f288e02edsi204020edc.15.2022.10.06.12.41.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Oct 2022 12:41:05 -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="zDEzi/HC"; 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 A00BB84E09; Thu, 6 Oct 2022 21:40: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=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="zDEzi/HC"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6366784DAA; Thu, 6 Oct 2022 21:40:42 +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-x530.google.com (mail-ed1-x530.google.com [IPv6:2a00:1450:4864:20::530]) (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 BD13184D99 for ; Thu, 6 Oct 2022 21:40: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=ilias.apalodimas@linaro.org Received: by mail-ed1-x530.google.com with SMTP id m15so4242583edb.13 for ; Thu, 06 Oct 2022 12:40:38 -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=zKgX0GuSOleR6TMszLnkxlsjzjpW8+nOg4U1SQF/60Q=; b=zDEzi/HCHYay5FaLyiUw81khmOJYurxCLkQ4IKZZmP1EHPbqQrQpHPDfbZ8kaDVBWx MiM5MUlx5pSZ0uqgUHf4jaTsKSn6yQ7w992v0jrx31xM81xSX2p0SCOnczGRf84l5cbt RMyqWXTIMgEZ3oQGkLXZHtxD/LQnmJNf9uyxug3l0CAXL3O84/NcjL2d4uU1tQ474KTE KmmzTmtXZsmJ/ukKcp1dGNpWZQaBbiH6g8Ni9aa/VzoLrL6EBCmyMw4B3RpIfYtEXAPy 9jJ6nPCcOeJnQ1cUGHfDtz3t3RI1ym4n+noeRCPkD08gjJBVKVrCDB29WPHIwhE1UbGy q0sg== 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=zKgX0GuSOleR6TMszLnkxlsjzjpW8+nOg4U1SQF/60Q=; b=XtSpRL4MCNYa/wSBIMV+zbQplz8ZaDB/humxRUgtq35uu0Dw6ENx3O4rd5x8gK+TCw VRLYRZqzXHMKGLasZAfnvw6mdLHUrCmJu3GEYt/GSPZiwxk2NJrlabBI+UFMWrKJsukc VwG5dhv5tzz4SgTp6U3pkTvELVcJoonlemnIlLgohLf0Wx51gt58RTWRd9CUfJzhctBl /ELAPlhgt/xS08y2mHNQ/SMR+9bga0azoXKL9Oq3/Fa5kH/McyTCyWOloK3QOYzQ4sZF 905kFwelv4ItaqKoboVuoph9Zx72rmCOzh6YXchFbdkIxCNiZaZEFhojd5p848aTwAOy ITIg== X-Gm-Message-State: ACrzQf3B8IY3yXYq23zyL49K3ReqQkou83F+VM83yg/0VS2SzQZ490tV lw6zYcj/1JedCJ517GDXv7F4rg== X-Received: by 2002:a50:bb68:0:b0:458:ab56:a8c0 with SMTP id y95-20020a50bb68000000b00458ab56a8c0mr1334065ede.103.1665085238332; Thu, 06 Oct 2022 12:40:38 -0700 (PDT) Received: from hades.. (ppp046103015185.access.hol.gr. [46.103.15.185]) by smtp.gmail.com with ESMTPSA id bo1-20020a170906d04100b0077b2b0563f4sm99147ejb.173.2022.10.06.12.40.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Oct 2022 12:40:37 -0700 (PDT) From: Ilias Apalodimas To: xypron.glpk@gmx.de Cc: takahiro.akashi@linaro.org, Ilias Apalodimas , u-boot@lists.denx.de Subject: [PATCH 2/2 v2] cmd: replace efi_create_handle/add_protocol with InstallMultipleProtocol Date: Thu, 6 Oct 2022 22:40:24 +0300 Message-Id: <20221006194028.28358-3-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221006194028.28358-1-ilias.apalodimas@linaro.org> References: <20221006194028.28358-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 Reviewed-by: Heinrich Schuchardt --- cmd/bootefi.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/cmd/bootefi.c b/cmd/bootefi.c index 3041873afbbc..b93c0d3d4c02 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -492,7 +492,7 @@ efi_status_t efi_run_image(void *source_buffer, efi_uintn_t source_size) efi_handle_t mem_handle = NULL, handle; struct efi_device_path *file_path = NULL; struct efi_device_path *msg_path; - efi_status_t ret; + efi_status_t ret, ret2; u16 *load_options; if (!bootefi_device_path || !bootefi_image_path) { @@ -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,9 +539,11 @@ 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); + ret2 = efi_uninstall_multiple_protocol_interfaces(mem_handle, + &efi_guid_device_path, + file_path, NULL); efi_free_pool(file_path); - return ret; + return (ret != EFI_SUCCESS) ? ret : ret2; } #ifdef CONFIG_CMD_BOOTEFI_SELFTEST