From patchwork Sat Mar 27 08:56:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 410127 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp2094117jai; Sat, 27 Mar 2021 01:56:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzU3UuKj9JA0py62tlMIji+sLaIoFlCdqI0ZMlyiRgUZiu1a8oc+tkDulIJgSQLsuUb1PJ9 X-Received: by 2002:aa7:cf16:: with SMTP id a22mr18893752edy.288.1616835382824; Sat, 27 Mar 2021 01:56:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616835382; cv=none; d=google.com; s=arc-20160816; b=u5KSD+BxX4Y8DD+J9uHWj+9AYhIGES0/BYlcFbfJq9PbrBCOZ+2qJ7u7oaVCbW3LyJ dWvR6ZvXJvfQqYkPxrZspVMwYpTAOZ0tGxYJpid9bN1tCbo+7UJp2YcIqXZNMJoG8dYW AzkGHQqWztQ8BdWEqMkKUrNFZVViheyuKWTGNlq3Vg/3ZYt513YRZi1ICAxZ2dlRnNL+ WpCcEA2QHrmgZYlE+/uGur9Hn14pioldDwsJUc0ifeIFYmzHyw/g7k+LwhXbl7SX2f7n slOpRZetvmHirERwB4UJX/3Z5Vxh3eiBnqO0EWaihnzYruCYecjqjFMiC2eBhcWOoKu+ CsbQ== 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=AyjI3XGlESzYv0a/L28joxNsM5VZKOdCOmBIWhEvt3U=; b=Btzq+CNv2IvmOhJsbHnNHXWgBmB88gxbwcWnX2ZZ8AEDDpwPsYWSjfDUOqMQSQh8wH u5jMuKxaK1SEP/knql23iqXhfl19WmXrrbA9PgSMzLxKyZ81zn4z3lEUhVaY/q5Tuj+Y BReSTZojQJaS+FjDUB1NBcx/sIiJyNseTr0qOPXL3YTuBsoNxh/MgByM/5ivj3MujHJT MPEmaS6DNiZ1aC8eVMq5U1FsrbCemwHvE5eMbMfx3U+4Ky/KLbyy03t8I3ZY3fgSeOPM i2MVZDX04PbGucxvBl0dYM5H7uwGAionEKNwgvvBNpoHJ6Kuu6SGhekKE6hcSuvqj3fT x1eA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zbxMhUdG; 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 b3si8473031edy.588.2021.03.27.01.56.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Mar 2021 01:56:22 -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=zbxMhUdG; 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 F083982816; Sat, 27 Mar 2021 09:56:18 +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="zbxMhUdG"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2E247827AE; Sat, 27 Mar 2021 09:56:17 +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.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) (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 16458827AE for ; Sat, 27 Mar 2021 09:56:11 +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=ilias.apalodimas@linaro.org Received: by mail-wr1-x435.google.com with SMTP id j18so7860318wra.2 for ; Sat, 27 Mar 2021 01:56:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=AyjI3XGlESzYv0a/L28joxNsM5VZKOdCOmBIWhEvt3U=; b=zbxMhUdG58njohugStc/FCFL+YOL3TJM3mpDTjXC7NfYKKuv+yUX3vCm6FETkqEw7c Js/Aa31FGYK0H0SEENRdjMmVOaM2MVn+vgqa2cTIBuR2+3m5GDY9z8YRWeu6zN3Lq9W8 4DElm9jwFl9W01Vc+s9jrIMe9PABKkSX2clhfnlPbEEBPC8skApHZ2+61gRc4Qx1B5RS cYhITzvE6rfzPAOT+O+zmnicJPTFWefWIVRyTtHRVkZiMbp+iuVpHUik6ficNtJkurOe CbYsuJ8Gl0pMubpMFmQ5UNpS62w/eUgTqn4AeySsJNUc0wLAFz6Zgxy1XxeTOezC6lWN tzsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=AyjI3XGlESzYv0a/L28joxNsM5VZKOdCOmBIWhEvt3U=; b=NaIVxpoarDVo88xpqLH2eHe2SdMkiUyCzK41OhG/YLBTLk8dQA36HHuFMzeobriDJT i9r+gq4D4YH/1k4cvoNcBe4IRx6k+VSFfVPHH9BKz1fHOD9jcMjKmYDe8TSQOhSrTIQs HX0w9Mb/VbtZXimVzwWBwWSQBtPtw7bL+GrCu36aSlkuxLuRljoxhTiUjOrlzeLX0coH ug16/JiZv+C1eYSs+mg/FWmSrvad21ShrXTiTSh8IWuRtoIHuMRPquqOMAOlAh6dcki0 EWnxG5RiDCpszROJoqkJrkIqo/EjTV4rvTFBIh/xBSDdgVsSrjkMeLlQe4Iv9GFvfS5m KoBQ== X-Gm-Message-State: AOAM533+6RY7zdgHXN20yp1pXHrO81znEmXXi33jgtWNQVgJvhNznxZ4 73vxKYwrcXRMqu5zrXv/E3eUtw== X-Received: by 2002:a5d:468e:: with SMTP id u14mr18792861wrq.359.1616835370549; Sat, 27 Mar 2021 01:56:10 -0700 (PDT) Received: from localhost.localdomain (ppp-94-64-113-158.home.otenet.gr. [94.64.113.158]) by smtp.gmail.com with ESMTPSA id y1sm14659106wmq.29.2021.03.27.01.56.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Mar 2021 01:56:10 -0700 (PDT) From: Ilias Apalodimas To: xypron.glpk@gmx.de Cc: Ilias Apalodimas , Alexander Graf , u-boot@lists.denx.de Subject: [PATCH] efi_loader: Cleanup get_var duplication Date: Sat, 27 Mar 2021 10:56:07 +0200 Message-Id: <20210327085607.1353026-1-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.31.0 MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.102.4 at phobos.denx.de X-Virus-Status: Clean get_var() is defined statically in efi_bootmgr.c and doesn't properly check a buffer allocation. Remove it completely and use the exported function from efi_var_common.c that does the same thing Signed-off-by: Ilias Apalodimas --- lib/efi_loader/efi_bootmgr.c | 36 ++---------------------------------- 1 file changed, 2 insertions(+), 34 deletions(-) -- 2.31.0 Reviewed-by: Heinrich Schuchardt diff --git a/lib/efi_loader/efi_bootmgr.c b/lib/efi_loader/efi_bootmgr.c index 46c8011344b9..1fe19237f9a6 100644 --- a/lib/efi_loader/efi_bootmgr.c +++ b/lib/efi_loader/efi_bootmgr.c @@ -30,38 +30,6 @@ static const struct efi_runtime_services *rs; * should do normal or recovery boot. */ -/** - * get_var() - get UEFI variable - * - * It is the caller's duty to free the returned buffer. - * - * @name: name of variable - * @vendor: vendor GUID of variable - * @size: size of allocated buffer - * Return: buffer with variable data or NULL - */ -static void *get_var(u16 *name, const efi_guid_t *vendor, - efi_uintn_t *size) -{ - efi_status_t ret; - void *buf = NULL; - - *size = 0; - ret = efi_get_variable_int(name, vendor, NULL, size, buf, NULL); - if (ret == EFI_BUFFER_TOO_SMALL) { - buf = malloc(*size); - ret = efi_get_variable_int(name, vendor, NULL, size, buf, NULL); - } - - if (ret != EFI_SUCCESS) { - free(buf); - *size = 0; - return NULL; - } - - return buf; -} - /** * try_load_entry() - try to load image for boot option * @@ -89,7 +57,7 @@ static efi_status_t try_load_entry(u16 n, efi_handle_t *handle, varname[6] = hexmap[(n & 0x00f0) >> 4]; varname[7] = hexmap[(n & 0x000f) >> 0]; - load_option = get_var(varname, &efi_global_variable_guid, &size); + load_option = efi_get_var(varname, &efi_global_variable_guid, &size); if (!load_option) return EFI_LOAD_ERROR; @@ -210,7 +178,7 @@ efi_status_t efi_bootmgr_load(efi_handle_t *handle, void **load_options) } /* BootOrder */ - bootorder = get_var(L"BootOrder", &efi_global_variable_guid, &size); + bootorder = efi_get_var(L"BootOrder", &efi_global_variable_guid, &size); if (!bootorder) { log_info("BootOrder not defined\n"); ret = EFI_NOT_FOUND;