From patchwork Wed May 26 18:01:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 448209 Delivered-To: patch@linaro.org Received: by 2002:a02:7a1b:0:0:0:0:0 with SMTP id a27csp5456021jac; Wed, 26 May 2021 11:01:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxMQT0F4hrnxM72f/BLISKj+QqubvF/IqoHaXkPnt6hZ2FZozGfeQRZTLtLhDM3UlTmlFoe X-Received: by 2002:a17:906:2e82:: with SMTP id o2mr35795604eji.388.1622052072405; Wed, 26 May 2021 11:01:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622052072; cv=none; d=google.com; s=arc-20160816; b=Uyd9FuI6gPdgiYGmcVEmLTZBCpjRnp62eFnyzN/ND5x5VAmqATo9Tr1Pad0MGDJ/Uz XBJqx62E4GvCXufIrGR+GA+u3meh3SO/JxBzN2nmX42uQtxADylKNGBcuZbI4QYdhTUY nh8TOANLzoS8Q9z8vi8ueP0GD0K4HizA+7vNvnqKSc9gnNADeew2OQ8EZ026+wnsvLdq zCRg3Pa4CVKmmlz1ky+q5t/SExn1TWHdwVKl+ai/4NOxUHZfs7459/1VWWoJn+gvXiKT iccj8xOZ36XgriWrB67oEGoyyz/o82mhK8Vqa50w0qcNs16ZhIfVs02Fsd5DKkvFKKws Rvwg== 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=3Z26wv0a0xiDVUBl7UwoHjYRaDcWVar/v73NfTvwUTk=; b=l6OKtfxKtbbD6zN46aBOpfCZsDBDgnd582W5vwACdtubYZYVjNg/qEEFiZax77e7px n1yUKc2jg1rmcPRZf9id/FU8+qykAmP3D7r9upOKATzviLRwsg+omemkHFAH6y4BYADI Wmj7+3V2z1Gzf13wu74CNgzVVc8Pfe2ulV9KTnq9blmzLZtlQmcSBNE3NDWuwbSmttSq meNNwQrXMArKG+/ZRNEa42QsO+1kkOWWjWckpf3FIsLs0dlUdS05qKbzg66ohwwlQd5a /qjjPo2owQGIbZHnxlMkm0RFi47Mtt4769YAegPqve/Gu3D+X720uATYUbTNNYSXJKs6 U8dQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=l0IauxYV; 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 g18si30053edt.478.2021.05.26.11.01.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 May 2021 11:01:12 -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=l0IauxYV; 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 38C5682AF4; Wed, 26 May 2021 20:01:09 +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="l0IauxYV"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C593482E23; Wed, 26 May 2021 20:01:06 +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.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-ed1-x52e.google.com (mail-ed1-x52e.google.com [IPv6:2a00:1450:4864:20::52e]) (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 C9E118047F for ; Wed, 26 May 2021 20:01:03 +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-ed1-x52e.google.com with SMTP id s6so2560897edu.10 for ; Wed, 26 May 2021 11:01:03 -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=3Z26wv0a0xiDVUBl7UwoHjYRaDcWVar/v73NfTvwUTk=; b=l0IauxYVYoGYsf05Nx+2IVadtyqneziWq47VZ7AMCKGaL2QIc+ez6pV+atui/4+Opq uZHvoMhl5XW23u0+Nwtwx5Uz0M8SU8pGgfJDEKaiv7BlUODoD1+fH7DJDvQkhijjpLv7 02yHBBsA8fL6ieoG2P7vVjYxFFCnN2km1CAQF1E90uUmJNioq3HqJU4qAnAcZT/pljMl G/tu8mWXCafmPnvIsdKd4YP6mPCPdJHDwKE1Wr9v3rYi3K8GRTM11DyQxtj0GdQBZthJ z2um04iqFRFTTlAL9xYmCq+8JaU0p3b3t3Y5CBtwujq8LwY8ylkko4+F66hKpiFfGx8E ekwA== 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=3Z26wv0a0xiDVUBl7UwoHjYRaDcWVar/v73NfTvwUTk=; b=Pb50gbTwkuMFLz9BQ2X8VqtxdvDN7vjiNHZE5OQoDLolBC5gFNPTwlU49Xzp7Q5MVg PvNE/W4f3/Iz9sLurwjrgpKKQUog7Oj5jZPqeWQBrZ50wIhNgb8Cn94ijQPNzvo0mQWM +M+kMTIa0KhJReRu2MtMlIm8mL0z4kRZaluhu8fsYSVwXpzxyvbSwLayNiPs9LQbSh/n y28bo9jY9untwNe8f1k3XKDwO49/NPfQSOIc5Ewru7xuflnUTEzBkH44Bvtk2KW72aaH vNSE2MZaT+7GAZLxmu827b7fHy8geAPChFbg6tVmlTfbqkY3Z6ne+fql060mqvTEfWCV UCDA== X-Gm-Message-State: AOAM533YpNHH/w5KG3QQt76gs3wOJagiaYlAgKgLc69LUreoOWoIOiQI ByD14jflYoteJK8DbZFrABYUeA== X-Received: by 2002:a05:6402:2713:: with SMTP id y19mr25345539edd.59.1622052063431; Wed, 26 May 2021 11:01:03 -0700 (PDT) Received: from apalos.home ([2a02:587:466e:1389:2e56:dcff:fe9a:8f06]) by smtp.gmail.com with ESMTPSA id a97sm6254337edf.72.2021.05.26.11.01.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 May 2021 11:01:03 -0700 (PDT) From: Ilias Apalodimas To: xypron.glpk@gmx.de, masahisa.kojima@linaro.org Cc: trini@konsulko.com, Ilias Apalodimas , Alexander Graf , u-boot@lists.denx.de Subject: [PATCH] efi_loader: Fix coverity warnings for efi tcg2 protocol Date: Wed, 26 May 2021 21:01:00 +0300 Message-Id: <20210526180100.25859-1-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.31.1 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 Coverity reported 3 warnings on the current code. CID 331856, 331855, 331854 on the latest scan. Fix the rest of the warnings by initializing the variables before passing them to tpm2_get_pcr_info(). In order to avoid future warnings and errors initialize them to 0 within the function as well, since the values are always OR'ed after querying the hardware. Signed-off-by: Ilias Apalodimas --- lib/efi_loader/efi_tcg2.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) -- 2.31.1 diff --git a/lib/efi_loader/efi_tcg2.c b/lib/efi_loader/efi_tcg2.c index 39074f754772..ee743f5951fb 100644 --- a/lib/efi_loader/efi_tcg2.c +++ b/lib/efi_loader/efi_tcg2.c @@ -403,6 +403,9 @@ static int tpm2_get_pcr_info(struct udevice *dev, u32 *supported_pcr, size_t i; int tpm_ret; + *supported_pcr = 0; + *active_pcr = 0; + *pcr_banks = 0; memset(response, 0, sizeof(response)); ret = tpm2_get_capability(dev, TPM2_CAP_PCRS, 0, response, 1); if (ret) @@ -481,7 +484,7 @@ out: static efi_status_t __get_active_pcr_banks(u32 *active_pcr_banks) { struct udevice *dev; - u32 active, supported, pcr_banks; + u32 active = 0, supported = 0, pcr_banks = 0; efi_status_t ret; int err; @@ -900,7 +903,7 @@ static efi_status_t create_specid_event(struct udevice *dev, void *buffer, struct tcg_efi_spec_id_event *spec_event; size_t spec_event_size; efi_status_t ret = EFI_DEVICE_ERROR; - u32 active, supported; + u32 active = 0, supported = 0; int err; size_t i;