From patchwork Wed Apr 3 15:43:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 785439 Delivered-To: patch@linaro.org Received: by 2002:adf:f001:0:b0:33e:7753:30bd with SMTP id j1csp384331wro; Wed, 3 Apr 2024 08:44:08 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWGj8jr1I8GChm/aHj6UQigS+Gv2lflOfp/BJcCIy9u1YiXZvvS+WkiLtWOleVfRcKIb/8WfiUpRRrs3KVqbtsv X-Google-Smtp-Source: AGHT+IGFS6+vDVzV4oRWPRBIEsu7h4JXfjPvYbdqiYmrIj8X9L+PE1qIWQRyiRfsxmo503+5h5GR X-Received: by 2002:ac2:4a8b:0:b0:515:ab7b:fc23 with SMTP id l11-20020ac24a8b000000b00515ab7bfc23mr4955919lfp.34.1712159048690; Wed, 03 Apr 2024 08:44:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712159048; cv=none; d=google.com; s=arc-20160816; b=KClRpAbZhAtkfN+b3ZHwoi0mYZ8YL2oXJxwAXtylAZgHIBA9DGLIJ4vlMATEPO1xlO tWgSRcOzWPf/V0g5ahUoYbdPNlCHzeSWxINkh1DEKbGKYB3Q4SufcKCNSLwgGmZpA+ik NDTRwIEU4qiZ8abG+kB9ynGC6RaDMSLQ/9thucD7E83CMAQGP+KaoSN7uC4pa3fmhJsU NeLPqcb//tskagB7J5nZNhklez5/4KLzVeN6VHWgF5HDruS7TPFkDNvEG5UqBJW3xlzx X0C2zwf1L+MkJjSSWT6XS61PHisPTxhxMbx7QowZVZe4TanrAs7ZKsNHQtzXn9y5Zo0R OgQw== 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=sDk2v1Fs89JO/27Mh6GzrbuSedkwTCoAobkt4ehItTo=; fh=iqDlUajERH/tChBngZmt8wwG8EJl962aNvCQY+ApDxA=; b=e1VKc8Hv1RFhU+HeSMzr6ueBPbPfwY68Nt41C7g1sUe3SekYHgXKtFv+TFq/7eBwtQ fd5IHOk9DwD6oGIpY3rVq+US250c+3OEf8e2d5QQ71znpO4Uk6NKfVlKKM54kvba5R41 NbsnCbMjkdHUr21J2wy+o3JxkJDL9I3Ppi5xf5BmK09ZX6/ngVQhdndeWNNDOmyHLLrw bZZpSq1xZTfZPaTA9eTNtCoj9O2ArPynT75ehZEx+8vEEt2uT7YkAgEjWAYA8QlRJTqD UdfNI0hhzwoNWRRE5O9ACngRraPeBWNPTEbSU7zKAgE+TXk3//vpErxPqdrD+sLnmHH8 a79w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZamfA1DL; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 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. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id m2-20020a50c182000000b00568386368c5si6776920edf.690.2024.04.03.08.44.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 08:44:08 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZamfA1DL; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 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 423F888238; Wed, 3 Apr 2024 17:44:07 +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="ZamfA1DL"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6FE4088359; Wed, 3 Apr 2024 17:44:05 +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-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) (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 7D207881AA for ; Wed, 3 Apr 2024 17:44:03 +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-x531.google.com with SMTP id 4fb4d7f45d1cf-56c0d1bddc1so7802114a12.3 for ; Wed, 03 Apr 2024 08:44:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712159043; x=1712763843; darn=lists.denx.de; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=sDk2v1Fs89JO/27Mh6GzrbuSedkwTCoAobkt4ehItTo=; b=ZamfA1DLaac9hTEbwdLugb1qoNsFB4dWCc7IuxpBh3NT/w0uI4EkJige8j0IHtFyzn U5NXD/B4slORss2+IBNbaQBiYabuo5M5zLj0zALdx/BmJn8hjH1Fu8oiPKV4A2/vHEVU w7Kk+GbwuZ+tLQgVmfx9ALuUXHugsKaFpOgT36zPZDuFB8BY6HITCFvNIIO1jhb9a2L5 YjI2gqgWY5BQvZlZ0r2of4FFzPh0hu7L+2p0gRw/cWqdz/lyVqNtZ6YqYmhgmoi/A7ju +8hRR7wb9+l+ULGk3QMkAHhwl6yV2QSLqNiVuwCMc6K9lwAaeuhFGdVX+bJs8vxeV0qS /Vmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712159043; x=1712763843; 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=sDk2v1Fs89JO/27Mh6GzrbuSedkwTCoAobkt4ehItTo=; b=WV8bBLN1/AxNBJCM1oYLfx6e8stj9yQEPcA43DW471a2PGhJ/HdJrYA1hu0CDGRu3q 4SO3kXZ75nadEsLBw4z2qrXx3RJzRv4iRXoOpIzZVP3NWfRwja3ejv9DlzosvSZsS4jb N7/euzSCK6uQ9OVLtbRJ80A5wkFJa2Rz+IrjKw2dDIRgERV+BDp3jKfqjoQPt5TTFU1K 9M00maVzcsuShsYWFRdTp359q8ffI0ddWbUV1dYvouHaS0mdziCus4d9tuHY/XxR5KLr ZDC0IGwKdm/zw/cZoug+vrl2ZKflxMMwbLk6C0+tqFFloSIGj0K5d3vFuTroGQl2y1k6 EU9Q== X-Forwarded-Encrypted: i=1; AJvYcCWjukn7t+lzjpEE2e4DO0AD1bxjAy6Qyt9IhE7GB1nn/VOhqA2tf+TJEEejATPbkZ7a1r5hNNlVJI6CG6apys13ZBaQcw== X-Gm-Message-State: AOJu0YwLfv3HLubKURVmedTmul6Blhjpm9BFOWxfib09/sHpEpsMZWjY F0mQJxEcy8NAfHhDh6jkrchSrscYpj9jzkqTArBjlDwg9bjAiW8G6FeOawx3ZIk= X-Received: by 2002:a17:906:f2d0:b0:a50:9190:b751 with SMTP id gz16-20020a170906f2d000b00a509190b751mr1246315ejb.10.1712159042452; Wed, 03 Apr 2024 08:44:02 -0700 (PDT) Received: from localhost.localdomain (ppp089210071137.access.hol.gr. [89.210.71.137]) by smtp.gmail.com with ESMTPSA id g4-20020a170906198400b00a46da83f7fdsm7935021ejd.145.2024.04.03.08.44.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 08:44:01 -0700 (PDT) From: Ilias Apalodimas To: heinrich.schuchardt@canonical.com Cc: Ilias Apalodimas , Heinrich Schuchardt , Ilias Apalodimas , Tom Rini , Simon Glass , u-boot@lists.denx.de Subject: [PATCH] efi_loader: Don't delete variable from memory if adding a new one failed Date: Wed, 3 Apr 2024 18:43:53 +0300 Message-ID: <20240403154353.440959-1-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.43.0 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.8 at phobos.denx.de X-Virus-Status: Clean From: Ilias Apalodimas Our efi_var_mem_xxx() functions don't have a replace variant. Instead we add a new variable and delete the old instance when trying to replace a variable. Currently we delete the old version without checking the new one got added Signed-off-by: Ilias Apalodimas Reviewed-by: Heinrich Schuchardt --- lib/efi_loader/efi_variable.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- 2.43.0 diff --git a/lib/efi_loader/efi_variable.c b/lib/efi_loader/efi_variable.c index 40f7a0fb10d5..b6e60626a260 100644 --- a/lib/efi_loader/efi_variable.c +++ b/lib/efi_loader/efi_variable.c @@ -342,11 +342,12 @@ efi_status_t efi_set_variable_int(const u16 *variable_name, ret = efi_var_mem_ins(variable_name, vendor, attributes, data_size, data, 0, NULL, time); } - efi_var_mem_del(var); if (ret != EFI_SUCCESS) return ret; + efi_var_mem_del(var); + if (var_type == EFI_AUTH_VAR_PK) ret = efi_init_secure_state(); else