From patchwork Wed Sep 8 21:30:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 507942 Delivered-To: patch@linaro.org Received: by 2002:a02:8629:0:0:0:0:0 with SMTP id e38csp968005jai; Wed, 8 Sep 2021 14:31:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxS9eG8iYGQKkBq4VtcgXehwieGXP7LsOCld0mS2ns3cgVeEuNF8oHYUCjq171l28EY0ea/ X-Received: by 2002:a17:907:1b02:: with SMTP id mp2mr194859ejc.196.1631136661737; Wed, 08 Sep 2021 14:31:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631136661; cv=none; d=google.com; s=arc-20160816; b=wjXb7gmU7dFM3S3EJVNAyxZFETxDiLxyZbrzu7LmjnFNaT0tKfC42sEInCmZipONdq FSRQwT7TF+P1fj99x4bp+A/Zt3GRkHQypZNz5rsOsKYwVZAH3tEAcwow2cGzu0lEiFfu 5KOzUzbMiajtjbgHvD/smwhIyJ+ypZGeq0h8zeos6PwS6r5HBp83EiOZQZo6tUu22Ymr TxXpDqV/KtCQTmLcfXqj99PECOzPKWYOt/erjY25XLiwaXVRX7NvX+fojy5QCfAbzUYV EIoZ+5uulxbQB4gOjJcWQLRLxUEeqeU1BtZqnQ4ty+95MrPxzGHcypX+fbJ2kVQ0/awS HtJA== 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=Bkuq9rSImUlxtlStfXXmZPj3cxh1FHCG21MiPx7T4zg=; b=HLjzfL+ibt8OBypW6JLRbVrLw1slRX7hVZct5cTCjREBTr274dF5GE/11uYm+OFwaD b2X4AjUsiUWAqmc5Lv1nofRdX9YidPN2uS+a1RiKg7pJZBMidulm38124TAPpzHx737j CN/PTrmlZ3hu+W9wXQS75HFxU04fkCDw+6siz6aZwSwhUdZBPXg5PMl/4K0PibJBEPw2 x24p5/B23F3UOWU4zm5JBFWGza4X9D9hAz90YEKq9+XIUiVqoz3ezruxCvdMNS54jVTr K4zKBAUZQLL7lr25SQ7nf+2x694Xc5S6hUJk8Ek1vxzRTuy0086ptyf3Qi/irTp8j0zO vzoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Q3kbOfHJ; 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 u4si249912ejy.271.2021.09.08.14.31.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Sep 2021 14:31:01 -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=Q3kbOfHJ; 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 5AF6083437; Wed, 8 Sep 2021 23:30:58 +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="Q3kbOfHJ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8392E8344B; Wed, 8 Sep 2021 23:30:57 +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 autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) (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 6E7E183430 for ; Wed, 8 Sep 2021 23:30:54 +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=ilias.apalodimas@linaro.org Received: by mail-wm1-x32d.google.com with SMTP id l18-20020a05600c4f1200b002f8cf606262so2656039wmq.1 for ; Wed, 08 Sep 2021 14:30:54 -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=Bkuq9rSImUlxtlStfXXmZPj3cxh1FHCG21MiPx7T4zg=; b=Q3kbOfHJDo6L31LGLRvejUTpE6o97IzWhpCBwFr39QjCdhQADYEPbU7aHx6LJGRIDv MjrpyBBq4mtYLd+x1mj5hSIihDw4/ZRXCOMUtXxXvDe+6V6tayhunlC1IGt4QbrSkqwC dRI+0KiW1fSQksaCQkUvYaxIrMBYwnbfu2Kbcs7+ad7EOqJcjTm9a0o0FzdcM34EipbL SFIKpRDs8wo93RMB95BpDSpl9T2vtampXl/PbsL9HzBL8q2U7W+a36C3HK+2J1XpUY4w fkdfBNfCKk4rQn84Gdvykd4zS8e0pqr04SE/yDEs34G1wyWDC2ggXSGSrNHI4kt7fMIO jJ+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Bkuq9rSImUlxtlStfXXmZPj3cxh1FHCG21MiPx7T4zg=; b=NNQ+WlD5NZDGNVEOWIL9NyxzwI+uYq0dO+KauKco6rQ1IKNfsPNVh4oKmMQOhhWAkY w6hoMsEyNpwHcoPWYRUbTaiCTPDb5QEBjfuG+nWxqI8yCwPg7rMzhbNqxNBU2W+6o5Hy hUqDZ9HKQr/sOLbdhQSngeBeFM1GKtab5+sW0B/lBQvhIqHd/KlaB9cQcuZPGO7A8ZxA nL10N2q3l8lL77Tc+xrtPU/i12Wt83jJYhVdnE0rp5VDuGHjD5T7hNHLbtISqzc8MhiW 3vuJ3odo9gqjUH65Tg0a3xThz4ulOhvRsNjWCxshcI+MXDSBTcoLtc/5xM0OhOr+Sx6t e3OQ== X-Gm-Message-State: AOAM532O6m/712yZQZIXyYAPkGVj8HjAEz6z8khBX5otxJprS4slQ+RQ ibcHjqJ00ezbNKPYoNbDQiGKpN1aI40NBhww X-Received: by 2002:a7b:c751:: with SMTP id w17mr258235wmk.162.1631136653900; Wed, 08 Sep 2021 14:30:53 -0700 (PDT) Received: from apalos.home ([2a02:587:4672:89f:2e56:dcff:fe9a:8f06]) by smtp.gmail.com with ESMTPSA id r129sm199858wmr.7.2021.09.08.14.30.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Sep 2021 14:30:53 -0700 (PDT) From: Ilias Apalodimas To: xypron.glpk@gmx.de Cc: masahisa.kojima@linaro.org, Ilias Apalodimas , Alexander Graf , u-boot@lists.denx.de Subject: [PATCH] efi_loader: Remove incorrect calls of EFI_CALL in TCG2 Date: Thu, 9 Sep 2021 00:30:49 +0300 Message-Id: <20210908213049.89268-1-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.33.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.103.2 at phobos.denx.de X-Virus-Status: Clean There is two unneeded EFI_CALL references in tcg2_measure_pe_image(). The first one in efi_search_protocol() and the second on in the device path calculation. The second isn't even a function we should be calling, but a pointer assignment, which happens to work with the existing macro. While at it switch the malloc call to a calloc, remove the unnecessary cast and get rid of an unneeded if statement before copying the device path Signed-off-by: Ilias Apalodimas --- lib/efi_loader/efi_tcg2.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) -- 2.33.0 Reviewed-by: Heinrich Schuchardt diff --git a/lib/efi_loader/efi_tcg2.c b/lib/efi_loader/efi_tcg2.c index 1319a8b37868..d026af2b2350 100644 --- a/lib/efi_loader/efi_tcg2.c +++ b/lib/efi_loader/efi_tcg2.c @@ -839,20 +839,19 @@ efi_status_t tcg2_measure_pe_image(void *efi, u64 efi_size, if (ret != EFI_SUCCESS) return ret; - ret = EFI_CALL(efi_search_protocol(&handle->header, - &efi_guid_loaded_image_device_path, - &handler)); + ret = efi_search_protocol(&handle->header, + &efi_guid_loaded_image_device_path, &handler); if (ret != EFI_SUCCESS) return ret; - device_path = EFI_CALL(handler->protocol_interface); + device_path = handler->protocol_interface; device_path_length = efi_dp_size(device_path); if (device_path_length > 0) { /* add end node size */ device_path_length += sizeof(struct efi_device_path); } event_size = sizeof(struct uefi_image_load_event) + device_path_length; - image_load_event = (struct uefi_image_load_event *)malloc(event_size); + image_load_event = calloc(1, event_size); if (!image_load_event) return EFI_OUT_OF_RESOURCES; @@ -875,10 +874,8 @@ efi_status_t tcg2_measure_pe_image(void *efi, u64 efi_size, goto out; } - if (device_path_length > 0) { - memcpy(image_load_event->device_path, device_path, - device_path_length); - } + /* device_path_length might be zero */ + memcpy(image_load_event->device_path, device_path, device_path_length); ret = tcg2_agile_log_append(pcr_index, event_type, &digest_list, event_size, (u8 *)image_load_event);