From patchwork Mon Jan 22 07:26:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahisa Kojima X-Patchwork-Id: 764617 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:10c4:b0:337:62d3:c6d5 with SMTP id b4csp979782wrx; Sun, 21 Jan 2024 23:28:36 -0800 (PST) X-Google-Smtp-Source: AGHT+IEwErGNblbJMvvR8ZlJtEIioypfaQDDvEyM/kNww0rCZ6zzX2K64dtYlWfXXrSrjZCDk4+k X-Received: by 2002:a2e:b706:0:b0:2cd:f341:5150 with SMTP id j6-20020a2eb706000000b002cdf3415150mr1526239ljo.13.1705908515772; Sun, 21 Jan 2024 23:28:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705908515; cv=none; d=google.com; s=arc-20160816; b=CWe7SuCmpzbZ0kqJichqEqrC0hxQi9mCce0gpyViBv73gmN50S96vAvCNhfyMOaLJ6 SlUaAkjoLviKwyFB7D+nOzjxzLsejkB9vE7yLXdzVKo3KhQqRxyRaQLQp+zMyfvkwCSo J/UUAdvKRlU2M4b5fNTvWywpB7Ytl4uyxFQq8CzhX60ktPnhu/UulR60ISjUZ2HQnaA+ Eb4WUJZq9+CD6cAYEgxFY7XnElMlKfZy3Kue+VtXDNxo0Mg2ssFF5ZKhVZLG26JaXIRH jbhCTPhix2jSSOILjC/Z7UdIzgc7TPFYVB+rvMGrmHM/cJsgsFCwKh55IINx8g/cJD6u C6iQ== 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=8om6QEIzofjENAff0O7c0R4K15koMexpSJCMBgdc8ZU=; fh=YtnCJplQ1DA0Rz8c1dg8CfrVxTgSI4BIXB9JUZxV1zk=; b=h9eeQf/LwrPIitNV7tgloXGMaIxz4SGVcSLrObfEeInLnArM/feU659pAxQNqbhTo2 eOK6bHLB4n26oN8ljaP+ZqVjCAJLvmbeqqNYQZa8TJzj0Zv2Y/h2ytS9IBcSFwGjymzf 8Sfk3jj89dElilRzXh3k7H6uztKfRmsQF9ogbaDUywxUJhAwGsVvDZTNIkZOgbVi14et vBbthORIMFfpqwuu1Zj2ly9vKcbXdk2xLbbhEsc+Azrf5rsmUpQZD+peU/V/6RjL2sPV TPiI4C562gSVTF9Kw/JLAdpONlVf9R659rnTb1eJHzSLKP9w6X3Q8axck717hW3t79aH JZiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oEaVkaLt; 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 e15-20020a5d4e8f000000b00337d607771bsi4633545wru.929.2024.01.21.23.28.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jan 2024 23:28:35 -0800 (PST) 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=oEaVkaLt; 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 17EAB87708; Mon, 22 Jan 2024 08:28:34 +0100 (CET) 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="oEaVkaLt"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2766487776; Mon, 22 Jan 2024 08:28:32 +0100 (CET) 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, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0: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 793D0876B1 for ; Mon, 22 Jan 2024 08:28:28 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=masahisa.kojima@linaro.org Received: by mail-pf1-x432.google.com with SMTP id d2e1a72fcca58-6d9344f30caso1680302b3a.1 for ; Sun, 21 Jan 2024 23:28:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1705908506; x=1706513306; 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=8om6QEIzofjENAff0O7c0R4K15koMexpSJCMBgdc8ZU=; b=oEaVkaLtT1YTVIyKUiTN055BynJZ6AAH2xWDLrXD6nTVnU6ampg9Sh2A4OhhszRxge VNL/K3VWJ/o+EPmG4SxHERIJWQlJJXXXZmUUtDVm+QEgYTK50lvZuQRpZ4YNoX8YlxL/ BEpHsG9jutRa6IuJZnxumsKR8DFrbpZsIFL0vkHxib2gIYoKr4iLdlhZhzf5PKELILm7 KD4g5UsQ9vQkifbrL9v52RlEX+WxoepGNIjxL8YYAKKtgpKBlJq112MgK/NRbfC3mmpC Z7qQdRU3gUaqym1RFkt+sipuePyyyGAk2vPSBbx+0hb3UOz5/p5P5OtUggo7Vz9ROSFg 9sqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705908506; x=1706513306; 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=8om6QEIzofjENAff0O7c0R4K15koMexpSJCMBgdc8ZU=; b=Gp/xSY6grU3FU4IlU1WJpdOnYQ+rLW7wUOTc98IrUphIsoyY6n7I3nbq49ixD3dT4r ClNZtCUtt1wTS5Ne+lAjjstfjnOvqyt293xZx1AkNY388poBhP7QJYQJscU5PtbXvh5M lgbz4av8aMEpZKIAMK/ngrfYzXCBi/PZ6UgvYAP3pv8h40RpoNKhowMLwUtCl+VGCK8D 2GWWrBudG+N81JG1clriiUlHZxjTE3R1q5t8j9yZTmnB0TERoasOzf0qx83oY7rmOo82 A2a9lqgYzp37+vg45YOhPddWa9IwPajmDvzNEpM3tJ5jZfvcTkjtjz7CADfzKNfZ8zNR tFCw== X-Gm-Message-State: AOJu0YwnhXS44/x3/7n3Fy9PqiIQKmvXIcZ+ssOq5Cw7xEDGL/QcIl8A U4ixclsslzqQZiOVu2TcPEdFPMnZ0wMj7RmhJXxsuSoH1fOeQgdnQVLioAVTmhCAO0nk9arZvon b X-Received: by 2002:a05:6a00:a8d:b0:6db:d65d:39ae with SMTP id b13-20020a056a000a8d00b006dbd65d39aemr2935340pfl.29.1705908505897; Sun, 21 Jan 2024 23:28:25 -0800 (PST) Received: from localhost ([164.70.16.189]) by smtp.gmail.com with ESMTPSA id y15-20020a62f24f000000b006d93ca7f8f3sm8891936pfl.150.2024.01.21.23.28.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jan 2024 23:28:25 -0800 (PST) From: Masahisa Kojima To: u-boot@lists.denx.de Cc: Heinrich Schuchardt , Ilias Apalodimas , Masahisa Kojima Subject: [PATCH] efi_loader: check efi_get_variable_int return value Date: Mon, 22 Jan 2024 16:26:17 +0900 Message-Id: <20240122072617.1104227-1-masahisa.kojima@linaro.org> X-Mailer: git-send-email 2.34.1 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 efi_get_variable_int() may fail, the buffer should be cleared before using it. Signed-off-by: Masahisa Kojima Addresses-Coverity-ID: 478333 ("Error handling issues") --- lib/efi_loader/efi_firmware.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/efi_loader/efi_firmware.c b/lib/efi_loader/efi_firmware.c index 9fd13297a6..fb83fa8113 100644 --- a/lib/efi_loader/efi_firmware.c +++ b/lib/efi_loader/efi_firmware.c @@ -407,11 +407,11 @@ efi_status_t efi_firmware_set_fmp_state_var(struct fmp_state *state, u8 image_in /* * GetVariable may fail, EFI_NOT_FOUND is returned if FmpState * variable has not been set yet. - * Ignore the error here since the correct FmpState variable - * is set later. */ - efi_get_variable_int(varname, image_type_id, NULL, &size, var_state, - NULL); + ret = efi_get_variable_int(varname, image_type_id, NULL, &size, + var_state, NULL); + if (ret != EFI_SUCCESS) + memset(var_state, 0, num_banks * sizeof(*var_state)); /* * Only the fw_version is set here.