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 A64D4EB64D9 for ; Mon, 19 Jun 2023 21:24:23 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7EC81862ED; Mon, 19 Jun 2023 23:24:08 +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="vqhL0gpl"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 42F4F86146; Mon, 19 Jun 2023 23:24:04 +0200 (CEST) Received: from mail-qv1-xf29.google.com (mail-qv1-xf29.google.com [IPv6:2607:f8b0:4864:20::f29]) (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 4221886181 for ; Mon, 19 Jun 2023 23:24:00 +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=raymond.mao@linaro.org Received: by mail-qv1-xf29.google.com with SMTP id 6a1803df08f44-62ffe4cabc0so27227026d6.1 for ; Mon, 19 Jun 2023 14:24:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1687209839; x=1689801839; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=mCU9N1AFhEZ2XggedFMZbDy1UDSuUfBDRy28hAEzgBw=; b=vqhL0gplnpmM2WKStycFMGmE0u/QyzS2AQ968xQACqSo568jPYLZRwTa6n3j7rqFcW g5Ycip2rEqJxhm7DXKx5HyDGnscejfYx4sqdLoXnC3bpoTIcY/8DcJobpZU7O/UW5Nzb WEdr6Syin0GYPF5rlR2yaUqQJcfzVecrI7JSwOn+KsWfLHtTU7GWR9mcAG4/OfO+B1ez QKzaRPr7b1piESR1JWF+ujQ/HQ6LGGSirxBNdZNTPxM2br4da/z7VnOZ4Pq6lKeUrqhy kxaLJj75b8pRSfUg7nx6Vn0oHDmjrKtzI+uzqj2PIUffLhqthhg/8wY/0ql1cEQo2XnO i3CA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687209839; x=1689801839; 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:message-id:reply-to; bh=mCU9N1AFhEZ2XggedFMZbDy1UDSuUfBDRy28hAEzgBw=; b=IUZcivgzWRoUCDcqQUCfWRDHaGhQvqt6oGKm0Ub79hzjTYexIXq66GKwigRJK4fwQK UbyNwoaVBtooRzRVvLv0odzJikf35SPiJTNgMVY3csIVbY+JmMMUjk5SqOzz7hcAttKH L5KO4T5BsxkBOO1C/R9eK/uD5XnHmJExMZNiMfd9w2uJGNbyyAMSLNv1K+Zild4IFYWy XdxQxtYUewA2yoJXZt6Br6KXiyvKCehWzTiSST4DdoMbUngoCh8177xtrhQdtC2ltGF6 HddFCmYMeP2SvtR3tWQSCxeJSpZZbxFoQW/nadb5+l/R7lrSdl43ql3qGgbRi/jmeotB bVFQ== X-Gm-Message-State: AC+VfDzhiwdr9xRy2G4zsUi9citt0G8rnRJ09obNE9kpfUsmXwwGBzos chsgVA1TTZFoge+LF8PFjplaDT1mgBIRTafed9k= X-Google-Smtp-Source: ACHHUZ6MqKBbBJ/8mwXAWk1+8MVAyx06azJtIsmEsONHHg1ltHH9/dLg4nn5Xf93JtlVa4C2lL2LGw== X-Received: by 2002:a05:6214:260f:b0:628:474b:aaef with SMTP id gu15-20020a056214260f00b00628474baaefmr15088997qvb.25.1687209838936; Mon, 19 Jun 2023 14:23:58 -0700 (PDT) Received: from ubuntu.localdomain (cpe688f2e182063-cm688f2e182060.sdns.net.rogers.com. [174.114.251.9]) by smtp.gmail.com with ESMTPSA id e8-20020a0ce3c8000000b005ef442226bbsm412407qvl.8.2023.06.19.14.23.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Jun 2023 14:23:58 -0700 (PDT) From: Raymond Mao To: u-boot@lists.denx.de Cc: Raymond Mao , Ilias Apalodimas , Heinrich Schuchardt , Simon Glass , Masahisa Kojima Subject: [PATCH v10 2/4] Fix incorrect return code of boot option update Date: Mon, 19 Jun 2023 14:22:59 -0700 Message-Id: <20230619212303.128288-3-raymond.mao@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230619212303.128288-1-raymond.mao@linaro.org> References: <20230619212303.128288-1-raymond.mao@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.8 at phobos.denx.de X-Virus-Status: Clean Correct the return code for out-of-memory and no boot option found Signed-off-by: Raymond Mao Reviewed-by: Ilias Apalodimas --- Changes in v7 - new patch file created cmd/bootmenu.c | 2 +- cmd/eficonfig.c | 2 +- lib/efi_loader/efi_bootmgr.c | 8 ++++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/cmd/bootmenu.c b/cmd/bootmenu.c index 01daddca7b..987b16889f 100644 --- a/cmd/bootmenu.c +++ b/cmd/bootmenu.c @@ -352,7 +352,7 @@ static struct bootmenu_data *bootmenu_create(int delay) * a architecture-specific default image name such as BOOTAA64.EFI. */ efi_ret = efi_bootmgr_update_media_device_boot_option(); - if (efi_ret != EFI_SUCCESS && efi_ret != EFI_NOT_FOUND) + if (efi_ret != EFI_SUCCESS) goto cleanup; ret = prepare_uefi_bootorder_entry(menu, &iter, &i); diff --git a/cmd/eficonfig.c b/cmd/eficonfig.c index 82a80306f4..e6e8a0a488 100644 --- a/cmd/eficonfig.c +++ b/cmd/eficonfig.c @@ -2314,7 +2314,7 @@ static int do_eficonfig(struct cmd_tbl *cmdtp, int flag, int argc, char *const a return CMD_RET_FAILURE; ret = efi_bootmgr_update_media_device_boot_option(); - if (ret != EFI_SUCCESS && ret != EFI_NOT_FOUND) + if (ret != EFI_SUCCESS) return ret; while (1) { diff --git a/lib/efi_loader/efi_bootmgr.c b/lib/efi_loader/efi_bootmgr.c index 97d5b8dc2b..28e800499c 100644 --- a/lib/efi_loader/efi_bootmgr.c +++ b/lib/efi_loader/efi_bootmgr.c @@ -663,11 +663,13 @@ efi_status_t efi_bootmgr_update_media_device_boot_option(void) NULL, &count, (efi_handle_t **)&volume_handles); if (ret != EFI_SUCCESS) - return ret; + goto out; opt = calloc(count, sizeof(struct eficonfig_media_boot_option)); - if (!opt) + if (!opt) { + ret = EFI_OUT_OF_RESOURCES; goto out; + } /* enumerate all devices supporting EFI_SIMPLE_FILE_SYSTEM_PROTOCOL */ ret = efi_bootmgr_enumerate_boot_option(opt, volume_handles, count); @@ -720,5 +722,7 @@ out: free(opt); efi_free_pool(volume_handles); + if (ret == EFI_NOT_FOUND) + return EFI_SUCCESS; return ret; } -- 2.25.1