From patchwork Thu Mar 25 19:55:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 408854 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp830962jai; Thu, 25 Mar 2021 12:55:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyH1SBn/3ndH6q4o5Q4wmu1RqD1RIRrJ9xC9OdQJg97tdSokyx5Ia6mEcP0ka/nUVWLMjZq X-Received: by 2002:a17:906:bcc7:: with SMTP id lw7mr11532542ejb.209.1616702128216; Thu, 25 Mar 2021 12:55:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616702128; cv=none; d=google.com; s=arc-20160816; b=krfcvAsTnV3X9J7hedaLKUrxtLgsmwQ2UPntVOUydgXNWnNaKErIH+ScHjYnrcML8E ZieBDTuBvHFcj9i68lyZJdUBPWl85HF4airElx8eF3iVbgqHWLDHDgiNYGcgWYfuBTl0 5A26MqAAI7tWXQJuukqTiREyUh/nu2SDKD/AwSQKSZWAclYXQHLqHgBthQMJFTK1rBR9 TOMHICTo8UcljWgskuCY9wwIQqX4bL50c/KDdNi5Zw/vVfc2uMprgw4PRNB/B/clcpUY 178nymVtnO+8GuI4Y+kpNv2qo/b3dt2U4qLIvqCVpz9vYJ0Bo+d2awB8vwj6aHlLpLYy PvUw== 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=Gk4iAcf7GZT7qpGVeVmwA+8aBuvClA4UKgZ9M1ST6CU=; b=byd6N7hLdlqBS642AwD+aOg2lYQ3y6ozxEzbfMZGOpynneV9l54+UGFGFTfXufdb5B BcA4gIO3onlOqPQcPU5jxsEF1rbqxBNCY+83/RVXgdSPY96yZPgMH2ocJ8VYKtYgkbiV toheVeKBt2nDNU/U32bDKmivM0cEfSZzYG7Q6ouJpzGUVrdW5CyFpsdbN3KVZb1wkxf3 OXku23thlGqxuMCQrbnkZVKo3QhGkWYQqOpe2K8SC626iQQUd9e/4eZU/kFqZ2pJ70sO dhz7VUiSoaCuHlpu4QGCBV0RIG/IZksxw4g/5LrRSnbPyYD6b1gWFNb4369yOsE8FZ0/ sPhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VHmi4d47; 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 di21si4723548edb.524.2021.03.25.12.55.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Mar 2021 12:55:28 -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=VHmi4d47; 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 3D70B8006D; Thu, 25 Mar 2021 20:55:24 +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="VHmi4d47"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 130FD805BF; Thu, 25 Mar 2021 20:55:23 +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-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) (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 4F4B380021 for ; Thu, 25 Mar 2021 20:55:20 +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-x436.google.com with SMTP id c8so3478652wrq.11 for ; Thu, 25 Mar 2021 12:55:20 -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=Gk4iAcf7GZT7qpGVeVmwA+8aBuvClA4UKgZ9M1ST6CU=; b=VHmi4d47hnk/LC95koMfRKoEew7GyMAlcOwlK9VO+kXjwxjuapLHCRwcz9TrS4rFJQ mubs2w0taFGC59AfoQHSoZFIyKpdCr/wKztdUlZqFzjNcOiGOIjX9qUAa6G4b0oTAs3l 45PPfqro/t29KhZGArwI1EPFmZTM2T+5nZeT3UYxpuk+lQreQMMD2DDjKXtpDpXlWz+u JtY6MrqispPi9GuCuvGdtAVALVfDASXexfNZaszbfbF+OzR9XJGh33iVp8ojHSSdfF21 uJmwVRmon8EKC6AbmnoKpnjJ+IiOQ5dl9Z5IYOf67qcT3NfMO8h8VpAovvzJNxRPu3jo l/Pw== 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=Gk4iAcf7GZT7qpGVeVmwA+8aBuvClA4UKgZ9M1ST6CU=; b=IorZArOxwJIqt0/v2HJ4HOmyL7PjM3Z6M71cu3YpwNADPSEs5Vszsha2+B6RWq5sVu AfANeUZMO3zEIaBma23wU+As5p1X1q4BuvGEWP4lROQ8Em1RgbExJbJb2N0p6oYHcRau FLrQaZWWjOm5C1aiuH2JB1JGHuE5yMaPd94BtBVlST7FRHJddaQRwbXjfz038wUH18GA ESJvo7Tnq9Lko0jXg7xyDK8eCZYzLNl9ipeQWSPnKj9KYM6zqrM1PnN5GpmRA2KkmBrP iJ5ujuKcTDobmm5c7sB/PIBHb0dVk/ViO41WfWqqepUghpO6OkJoG+11q5fPZJnA5BbX j0KQ== X-Gm-Message-State: AOAM532jEZg4ukrqV9wzjvL2TDzu9qedQiOeINfCqhbUvH1AYPwetI1z WJkEmsXWOR4NgD2uWPadAdPv1aqOVlvuLkx/ X-Received: by 2002:adf:f010:: with SMTP id j16mr1475317wro.251.1616702119835; Thu, 25 Mar 2021 12:55:19 -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 c2sm7009925wme.15.2021.03.25.12.55.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Mar 2021 12:55:19 -0700 (PDT) From: Ilias Apalodimas To: xypron.glpk@gmx.de Cc: Ilias Apalodimas , Alexander Graf , u-boot@lists.denx.de Subject: [PATCH] efi_loader: Clean up file size calculations Date: Thu, 25 Mar 2021 21:55:16 +0200 Message-Id: <20210325195516.1265125-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 We recently added a common function for calculating file size, instead of copy pasting the code around. Switch one of the occurences over to the common function Signed-off-by: Ilias Apalodimas --- lib/efi_loader/efi_boottime.c | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) -- 2.31.0 Reviewed-by: Heinrich Schuchardt diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index 41b8949b0424..a21abefd8ca8 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -1877,7 +1877,6 @@ static efi_status_t efi_load_image_from_file(struct efi_device_path *file_path, void **buffer, efi_uintn_t *size) { - struct efi_file_info *info = NULL; struct efi_file_handle *f; efi_status_t ret; u64 addr; @@ -1888,18 +1887,7 @@ efi_status_t efi_load_image_from_file(struct efi_device_path *file_path, if (!f) return EFI_NOT_FOUND; - /* Get file size */ - bs = 0; - EFI_CALL(ret = f->getinfo(f, (efi_guid_t *)&efi_file_info_guid, - &bs, info)); - if (ret != EFI_BUFFER_TOO_SMALL) { - ret = EFI_DEVICE_ERROR; - goto error; - } - - info = malloc(bs); - EFI_CALL(ret = f->getinfo(f, (efi_guid_t *)&efi_file_info_guid, &bs, - info)); + ret = efi_file_size(f, &bs); if (ret != EFI_SUCCESS) goto error; @@ -1909,7 +1897,6 @@ efi_status_t efi_load_image_from_file(struct efi_device_path *file_path, * allocate a buffer as EFI_BOOT_SERVICES_DATA. The caller has to * update the reservation according to the image type. */ - bs = info->file_size; ret = efi_allocate_pages(EFI_ALLOCATE_ANY_PAGES, EFI_BOOT_SERVICES_DATA, efi_size_in_pages(bs), &addr); @@ -1926,7 +1913,6 @@ efi_status_t efi_load_image_from_file(struct efi_device_path *file_path, *size = bs; error: EFI_CALL(f->close(f)); - free(info); return ret; }