From patchwork Wed May 31 17:45:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raymond Mao X-Patchwork-Id: 1788474 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=sY4/XBMc; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QWcCG0wXMz20Py for ; Thu, 1 Jun 2023 03:46:50 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 899DD8626E; Wed, 31 May 2023 19:46:47 +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="sY4/XBMc"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0E9308627C; Wed, 31 May 2023 19:46:46 +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, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-qt1-x82e.google.com (mail-qt1-x82e.google.com [IPv6:2607:f8b0:4864:20::82e]) (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 7644A86273 for ; Wed, 31 May 2023 19:46:43 +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-qt1-x82e.google.com with SMTP id d75a77b69052e-3f6b34d2fdcso35780271cf.1 for ; Wed, 31 May 2023 10:46:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1685555202; x=1688147202; 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=zwKrZLJv0bODrOlePqGhJ/r1IKHC/k8hJwcfr+L/N2s=; b=sY4/XBMcrn/8YZPCW04UUmD2BxdUmn9SIAIJAQSOXeZpNRZdaXxtS5ReZdYP5icw4G MFTWFxCWEcuKVUwJddfB9y2z7CuA0Xw8i/I+Nyuw1v85qu3Pth/0JP4aE0R4xsHYUZNl f6BxmOs/YVTtqeRrHHTdgeiJoAuSY/UxHsqVj+0/9IRhfE/WePpWw0fmULhp4ng+MzQ9 RsS8DEOaWr2GHxMfluNXk3YS4EY38wZ6FwhRHU19WATirXJIhfgkTaRoy2uz1SSj993X B2FaW0INTZ2g3vOr2hAl4afPmnqUuzvCkQZCuIqps5eWLDszsYeLau0io9785t7w2KK0 +wKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685555202; x=1688147202; 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=zwKrZLJv0bODrOlePqGhJ/r1IKHC/k8hJwcfr+L/N2s=; b=U4K00ls/01v+8jSN5Dd0EEsPP9LHAwnsjLxAO4DTDrLf+LR4cbVxJanxekNPplDVjP 0DvO6kpHLnerUhlIyCtbt6NkjPIEnberpPAr3yKPCVrtmc1FwY81p91ABQZ4dhqOEMWs OlkZgQdK0NrIb3DeFKzv5szp7wLLdqMl5NUv/ccA7sEN7AQPOnwYEyfhonsXaL7MTsqW emZZ+HvJU6GLY9MitxXPEuAvjY33N7BRL/GfSThjJPiygPVEFp08UhX4VWbS+ckAQIxv 7Uz/gPsWrXMJkgzHHRGfvfHOXbcSetKuNo9kfFFRP+KWdCgxDciFgRV/HnwtzTKww/dl S26Q== X-Gm-Message-State: AC+VfDzdCFKkdESOk/+bDWcuwuKRk3z0l+9+27Rffd3bmT69qQewU5OS PSixzVqD/V9TbKkt5YVqo29GHWB7sKxcO1hht70= X-Google-Smtp-Source: ACHHUZ4KwCXJcJk3lpKvs2QjwSvq56yOgEBe/ZyWdoBJ9WzuxjHzQyUwsbsG+6bIrkOXREJX2+1aoA== X-Received: by 2002:a05:622a:10a:b0:3f6:aff0:6dfe with SMTP id u10-20020a05622a010a00b003f6aff06dfemr6634708qtw.37.1685555202026; Wed, 31 May 2023 10:46:42 -0700 (PDT) Received: from ubuntu.localdomain (cpe688f2e182063-cm688f2e182060.sdns.net.rogers.com. [174.114.251.9]) by smtp.gmail.com with ESMTPSA id a26-20020ac84d9a000000b003f6aa9d7883sm6193037qtw.13.2023.05.31.10.46.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 May 2023 10:46:41 -0700 (PDT) From: Raymond Mao To: u-boot@lists.denx.de Cc: Raymond Mao , Heinrich Schuchardt , Ilias Apalodimas , Simon Glass , Masahisa Kojima Subject: [PATCH v7 2/4] Fix incorrect return code of boot option update Date: Wed, 31 May 2023 10:45:15 -0700 Message-Id: <20230531174515.41758-3-raymond.mao@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230531174515.41758-1-raymond.mao@linaro.org> References: <20230531174515.41758-1-raymond.mao@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.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 48cd5f0636..95559ad6dd 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; }